我刚刚注册了一个 Godaddy 服务器来测试我正在编写的 PHP 脚本。我正在使用 PHPMailer 发送电子邮件,它使用 Godaddy 电子邮件主机:relay-hosting.secureserver.net
问题是我想将电子邮件标记为来自“me”@gmail.com
当我在 AddReplyTo 字段中使用我的 gmail 地址发送电子邮件时,收件人电子邮件帐户会将其直接发送到垃圾文件夹。
我知道这里存在一个基本问题,即我发送了相互冲突的标题,这可能就是它被放入垃圾文件夹的原因。
有人可以向我解释如何解决这个问题。谢谢你。
代码:
try {
$mail = new PHPMailer(true);
$mail->IsSMTP(); // Using SMTP.
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2; // Enables SMTP debug information - SHOULD NOT be active on production servers!
$mail->SMTPAuth = false; // Enables SMTP authentication.
$mail->Host = "relay-hosting.secureserver.net"; // SMTP server host.
$mail->AddReplyTo('me@gmail.com', 'Me');
$mail->AddAddress('them@hotmail.co.uk', 'Them');
$mail->SetFrom('me@gmail.com', 'Me');
$mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML("Hi, this is an test email");
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage();
} catch (Exception $e) {
echo $e->getMessage();
}