2015-09-25 125 views
0

我正在尝试使用PHP Mailer发送HTML电子邮件。但它不是发送。 这里是我的代码:我无法使用PHPMailer发送Html电子邮件

$mail->From = $from; 
$mail->FromName = $fromname; 
$mail->addAddress($to, $toname);  // Add a recipient 
$mail->IsHTML(true); 
$mail->Subject = $subject; 
$mail->Body = "`<a href='www.google.com'>click here </a>`"; 
if(!$mail->send()) { 
    echo 'Message could not be sent.'; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
} else { 
    echo 'Message Sent'; 
} 

还有一,如果我发短信,它工作正常。但在HTML中它不发送电子邮件,告诉我的消息

+0

采取这些反引号了。 – Synchro

+0

完成但不起作用 –

回答

0

试试这个:

$mail->From = $from; 
$mail->FromName = $fromname; 
$mail->addAddress($to, $toname);  // Add a recipient 
$mail->IsHTML(true); 
$mail->Subject = $subject; 
$message = '<html><body><a href='www.google.com'>click here </a></body></html>'; 
$mail->Body= $message; 
if(!$mail->send()) { 
    echo 'Message could not be sent.'; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
} else { 
    echo 'Message Sent'; 
} 
+0

无法正常工作html标记 –