【问题标题】:SMTP Mail Error on both server and localhost服务器和本地主机上的 SMTP 邮件错误
【发布时间】:2025-12-05 21:10:02
【问题描述】:

我有一个已配置并正在运行的 zoho.com 电子邮件帐户。在 GoDaddy 上,我正在托管我的网站并配置了我的邮件,以便通过该网站发送的任何邮件都可以在 zoho mail 接收。直到上周,此设置都运行良好。现在我遇到了错误,我不知道是什么触发了它们。

当我尝试向任何帐户发送邮件时,我在 GoDaddy 服务器上收到以下错误:

SMTP -> 错误:无法连接到服务器:连接被拒绝 (111) SMTP 错误:无法连接到 SMTP 主机。

同一脚本在本地主机上出现以下错误:

SMTP -> 错误:无法连接到服务器:连接尝试 失败,因为连接方没有正确响应后 一段时间,或建立连接失败,因为已连接 主机未能响应。 (10060)

我已尝试以下方法来纠正错误(在 localhost 和 GoDaddy 上):

  • 将端口号更改为 25,465 和 587

  • 将 smtp 服务器从 smtp.zoho.com 更改为 relay-hosting.secureserver.net

  • 将 ssl 更改为 tls,反之亦然

  • 完全删除了 SMTPSecure 参数

  • 将超时变量增加到 1000

  • 已验证邮件帐户存在且正常运行

  • 已验证邮件帐户具有有效的密码和用户名。

可以在here找到一个工作演示。我已经回应了错误以及为了这个问题而发送的消息。

编辑 1 我注释掉了“$mail->Host="smtp.zoho.com" 并收到以下错误:

SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not 从服务器接受:SMTP -> FROM SERVER: SMTP -> ERROR: HELO not 从服务器接受:SMTP -> 错误:未从服务器接受身份验证: SMTP -> 注意:检查是否已连接 SMTP 错误时捕获到 EOF: 无法验证。

这是否意味着 GoDaddy 未对凭据进行身份验证?

编辑 2:我在 zoho mail 上的设置是:

传入服务器:poppro.zoho.com,端口:995,SSL (POP)
传入服务器:imappro.zoho.com,端口:993,SSL (IMAP) 传出 服务器:smtp.zoho.com,端口:465,SSL(POP 和 IMAP)

【问题讨论】:

  • 假设您已经更改了上面的密码。
  • 不,电子邮件和密码如问题中所述。在我的智慧结束:(
  • 在尝试块$mail->Mailer = 'smtp'中再添加一个参数;
  • @RahulSingh 没有变化! Godaddy服务器上的同样错误:(
  • 如果您注释掉主机 (zoho mx),您可能会默认尝试通过 localhost 发送邮件,这可能不是您想要的。

标签: php email smtp


【解决方案1】:

尝试使用以下代码:

<?php
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
    //SMTP needs accurate times, and the PHP time zone MUST be set
    //This should be done in your php.ini, but this is how to do it if you don't have access to that
    #require '../PHPMailerAutoload.php';

    //Create a new PHPMailer instance
    $mail = new PHPMailer;

    //Tell PHPMailer to use SMTP
    $mail->isSMTP();
    //Enable SMTP debugging
    // 0 = off (for production use)
    // 1 = client messages
    // 2 = client and server messages
    $mail->SMTPDebug = 3;

    //Ask for HTML-friendly debug output
    $mail->Debugoutput = 'html';

    //Set the hostname of the mail server
    $mail->Host = 'smtp.zoho.com';

    // use
    // $mail->Host = gethostbyname('smtp.zoho.com');
    // if your network does not support SMTP over IPv6

    //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
    $mail->Port = 465;

    //Set the encryption system to use - ssl (deprecated) or tls
    //$mail->SMTPSecure = 'tls';

    //Whether to use SMTP authentication
    $mail->SMTPAuth = true;

    //Username to use for SMTP authentication - use full email address for gmail
    $mail->Username = "care@subillion.com";

    //Password to use for SMTP authentication
    $mail->Password = "care@subillion";

    //Set who the message is to be sent from
    $mail->setFrom('care@subillion.com', 'care@subillion.com');

    //Set an alternative reply-to address
    #$mail->addReplyTo('replyto@example.com', 'First Last');

    //Set who the message is to be sent to
    $mail->AddAddress($touser, $username);

    $mail->Subject = $subject;
    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
    $mail->MsgHTML($msg);
    echo $msg;
    //$mail->AddAttachment('img/logo-dark.png');      
    $mail->Send();

    // echo "Message Sent OK</p>\n";
} catch (Exception $e) {
    // echo $e->getMessage(); //Boring error messages from anything else!
}
?>

编辑:如果仍然无法正常工作,那么您必须进行正确的配置设置,如下所示(例如):

Non-SSL Settings
(NOT Recommended)
Username:   jon@domain.com
Password:   Use the email account’s password.
Incoming Server:    mail.domain.com
IMAP Port: 143
POP3 Port: 110
Outgoing Server:    mail.domian.com
SMTP Port: 25
Authentication is required for IMAP, POP3, and SMTP.

【讨论】:

  • 感谢您的回答。不幸的是,我在 GoDaddy 上的脚本遇到了同样的错误。我认为这可能是因为文件没有被正确调用,所以只是为了检查脚本是否确实可以与主机通信,我注释掉了“$mail->Host”。我得到了这个: SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> ERROR:服务器不接受身份验证:SMTP -> 注意:在检查是否已连接 SMTP 时捕获 EOF 错误:无法进行身份验证。
  • 我认为您的 EMAIL 配置设置不正确。请参阅我编辑的答案。
  • 在哪里可以找到这些设置?另外,相同的 SSL 设置是什么?
  • 登录到 cpanel > 转到电子邮件帐户 > 单击电子邮件帐户 > 配置。然后你会发现这些细节。
  • 我无法更改我的 POP/IMAP 设置!
最近更新 更多