【问题标题】:I am unable to send Html emails using PHPMailer我无法使用 PHPMailer 发送 Html 电子邮件
【发布时间】:2015-09-25 09:58:46
【问题描述】:

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

【问题讨论】:

  • 去掉那些反引号。
  • 做了但没用

标签: php email html-email phpmailer


【解决方案1】:

试试这个:

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

【讨论】:

    猜你喜欢
    • 2015-09-06
    • 2020-11-25
    • 2019-01-19
    • 2023-03-20
    • 2017-07-19
    • 2017-10-05
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    相关资源
    最近更新 更多