【问题标题】:phpmailer body, want to use html and phpphpmailer body,想用html和php
【发布时间】:2015-01-23 21:45:33
【问题描述】:

我正在尝试为我的网站构建验证邮件,但我似乎无法让 PHPmailer 包含 html 和 php。我可以使用正确的正文将验证邮件发送到正确的邮件地址,代码如下:

$mail->Body = 'Please verificate your account by clicking on the following link: http:localhost/confirm.php?passkey=' . $confirm_code;

现在我试图让邮件中的链接成为一个实际的链接,我试过这个(见下面的代码)但是没有用

$mail->Body = 'Please verificate your account by clicking on the following link: <a href=\"http:localhost/confirm.php?passkey= . $confirm_code\">http:localhost/confirm.php?passkey=' . $confirm_code . '</a>';

我已将 PHPmailer 设置为使用 html 发送电子邮件:

$mail->Debugoutput = 'html';

谁能告诉我这里有什么问题?

【问题讨论】:

标签: php html phpmailer


【解决方案1】:

设置Debugoutput 与发送HTML 无关——它是错误输出格式。您需要致电isHTML() 或使用msgHTML() 设置您的内容。也没有“验证”这样的词,它只是“验证”。

【讨论】:

  • 我已经弄清楚了ishtml(见上面的评论),但感谢英文的更正,它不是我的母语,所以我有时还是会出错;)
  • 它只是让你听起来像乔治 W 布什!
【解决方案2】:

你也必须连接链接变量。

另外,在单引号内你不需要使用反斜杠:

$mail->Body = 'Please verificate your account by clicking on the following link: <a href="http:localhost/confirm.php?passkey='. $confirm_code.'">http:localhost/confirm.php?passkey=' . $confirm_code . '</a>';

【讨论】:

  • 感谢您的代码,但我还需要添加此代码:$mail->IsHTML(true);
猜你喜欢
  • 2021-08-05
  • 1970-01-01
  • 1970-01-01
  • 2013-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-11
  • 2012-06-12
相关资源
最近更新 更多