繁体   English   中英

我无法使用PHPMailer发送HTML电子邮件

[英]I am unable to send Html emails using PHPMailer

我正在尝试使用PHP Mailer发送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中,它不会发送电子邮件并向我显示消息

尝试这个:

$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';
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM