Godaddy 服务器上的 PHPMailer,设置正确吗?

标签 php email smtp phpmailer

我刚刚注册了一个 godaddy 服务器来测试我正在编写的 PHP 脚本。我正在使用 PHPMailer 发送电子邮件,它使用 godaddy 电子邮件主机:relay-hosting.secureserver.net

问题是我想将电子邮件标记为来自“我”@gmail.com

当我在 AddReplyTo 字段中使用我的 gmail 地址发送电子邮件时,收件人电子邮件帐户将其直接发送到垃圾文件夹。

我知道这里有一个根本性的问题,我正在发送冲突的 header ,这可能就是它被放入垃圾文件夹的原因。

有人可以向我解释一下我该如何解决这个问题。谢谢。

代码:

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(); 
}

最佳答案

亚历克斯是对的。您需要指定您域中的发件人地址,me@myhostedexampledomain.com。关于 Pekka 关于使用 Google 的服务器发送电子邮件无效的评论。使用 Go Daddy 共享主机,您必须使用 relay-hosting.secureserver.net 发送。

关于Godaddy 服务器上的 PHPMailer,设置正确吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10984352/

相关文章:

通过电子邮件报告 Drupal 错误

PHPMailer 与 mandrill smtp 出现连接错误

.net - PickupDirectoryFromIis、Sender 属性和 SMTP MAIL FROM 信封

php - Javascript、PHP、保存字段值

php - Swift - 在应用程序内购买 - 从 mysql 数据库加载产品

php - Cakephp 如何基于另一个虚拟字段创建虚拟字段

python - pyramid_mailer 不发送电子邮件?

php - Controller 内查询的 Codeigniter 更新

email - (Mailgun) 入站路由 catch_all() 不转发自动回复

email - 使用 Golang 通过 G Suite 发送电子邮件