服务器和本地主机上的 SMTP 邮件错误

SMTP Mail Error on both server and localhost

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

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

SMTP -> ERROR: Failed to connect to server: Connection refused (111) SMTP Error: Could not connect to SMTP host.

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

SMTP -> ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

我已尝试通过以下方式更正错误(在本地主机和 GoDaddy 上):

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

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

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: AUTH not accepted from server: SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate.

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

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

Incoming server: poppro.zoho.com, Port: 995, SSL (POP)
Incoming server: imappro.zoho.com, Port: 993, SSL (IMAP) Outgoing server: smtp.zoho.com, Port: 465, SSL (POP and IMAP)

尝试使用以下代码:

<?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.