php邮件正文,想使用 html 和 php

phpmailer body, want to use html and php

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

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

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

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

谁能告诉我这是什么问题?

您还必须连接 link 变量。

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

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

设置Debugoutput与发送HTML无关——这是错误输出格式。您需要调用 isHTML() 或使用 msgHTML() 设置您的内容。也没有 'verificate' 这样的词,它只是 'verify'.