GoDaddy PHPMailer成功但没有电子邮件(在调试模式下没有错误)

时间:2016-12-22 12:18:47

标签: php phpmailer snmp

将PHPMailer与GoDaddy托管结合使用还有另一个难题。以下配置至少在最近几个月运行且没有任何问题,但是,尽管在调试模式中没有错误并且“成功”作为服务器响应,但不再发送电子邮件。实际上,请看一下日志文件,也许,我遗漏了一些明显的东西?

$mail = new PHPMailer. 
$mail->IsSMTP();
$mail->SMTPDebug = 4; 


$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false;

调试结果:

2016-12-22 12:12:40 Connection: opening to localhost:25, timeout=300, options=array (
                                      )
2016-12-22 12:12:40 Connection: opened
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "220-We do not authorize the use of this system to transport unsolicited, 
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      220-We do not authorize the use of this system to transport unsolicited, 
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      220-We do not authorize the use of this system to transport unsolicited, 
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "220 and/or bulk e-mail.
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      220-We do not authorize the use of this system to transport unsolicited, 
                                      220 and/or bulk e-mail.
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 220-n3plcpnl0096.prod.ams3.secureserver.net ESMTP Exim 4.87 #1 Thu, 22 Dec 2016 05:12:45 -0700 
                                      220-We do not authorize the use of this system to transport unsolicited, 
                                      220 and/or bulk e-mail.
2016-12-22 12:12:45 CLIENT -> SERVER: EHLO www.#####.com
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250-SIZE 52428800
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250-8BITMIME
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250-PIPELINING
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250-AUTH PLAIN LOGIN
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250-STARTTLS
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data was "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250 HELP
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      250 HELP
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 250-n3plcpnl0096.prod.ams3.secureserver.net Hello www.#####.com [127.0.0.1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      250 HELP
2016-12-22 12:12:45 CLIENT -> SERVER: MAIL FROM:<info@#####.com>
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250 OK
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250 OK
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 250 OK
2016-12-22 12:12:45 CLIENT -> SERVER: RCPT TO:<info@#####.com>
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250 Accepted
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250 Accepted
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 250 Accepted
2016-12-22 12:12:45 CLIENT -> SERVER: DATA
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "354 Enter message, ending with "." on a line by itself
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "354 Enter message, ending with "." on a line by itself
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2016-12-22 12:12:45 CLIENT -> SERVER: Date: Thu, 22 Dec 2016 12:12:40 +0000
2016-12-22 12:12:45 CLIENT -> SERVER: To: info@#####.com
2016-12-22 12:12:45 CLIENT -> SERVER: From: Anonymous <info@#####.com>
2016-12-22 12:12:45 CLIENT -> SERVER: Reply-To: Anonymous <info@#####.com>
2016-12-22 12:12:45 CLIENT -> SERVER: Subject: General Enquiry
2016-12-22 12:12:45 CLIENT -> SERVER: Message-ID: <4784799123b2e08d2153a654b78eb1d0@www.#####.com>
2016-12-22 12:12:45 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/)
2016-12-22 12:12:45 CLIENT -> SERVER: MIME-Version: 1.0
2016-12-22 12:12:45 CLIENT -> SERVER: Content-Type: text/html; charset=UTF-8
2016-12-22 12:12:45 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2016-12-22 12:12:45 CLIENT -> SERVER:
2016-12-22 12:12:45 CLIENT -> SERVER: Full Name: Anonymous<br>
2016-12-22 12:12:45 CLIENT -> SERVER: Email address: info@#####.com<br>
2016-12-22 12:12:45 CLIENT -> SERVER: Phone: ##########<br>
2016-12-22 12:12:45 CLIENT -> SERVER:
2016-12-22 12:12:45 CLIENT -> SERVER: .
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "250 OK id=1cK2En-001yR0-3J
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "250 OK id=1cK2En-001yR0-3J
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 250 OK id=1cK2En-001yR0-3J
2016-12-22 12:12:45 CLIENT -> SERVER: QUIT
2016-12-22 12:12:45 SMTP -> get_lines(): $data was ""
2016-12-22 12:12:45 SMTP -> get_lines(): $str is "221 n3plcpnl0096.prod.ams3.secureserver.net closing connection
                                      "
2016-12-22 12:12:45 SMTP -> get_lines(): $data is "221 n3plcpnl0096.prod.ams3.secureserver.net closing connection
                                      "
2016-12-22 12:12:45 SERVER -> CLIENT: 221 n3plcpnl0096.prod.ams3.secureserver.net closing connection
2016-12-22 12:12:45 Connection: closed
{"response":"success"}

这是实际的PHP文件:

<?php

session_cache_limiter('nocache');
header('Expires: ' . gmdate('r', 0));
header('Content-type: application/json');

// Include PHPMailer class
include("PHPMailer/PHPMailerAutoload.php");


$to_address = "info@#####.com"; 



// Verify if data has been entered
if(!empty($_POST['email']) || !empty($_POST['fullname']) || !empty($_POST['phone'])) {

    $subjectline = $_POST['subjectline'];
    $email = $_POST['email'];
    $fullname = $_POST['fullname'];
    $phone = $_POST['phone'];

    // Configure the fields list that you want to receive on the email.
    $fields = array(
        0 => array(
            'text' => 'Full Name',
            'val' => $_POST['fullname']
        ),
        1 => array(
            'text' => 'Email address',
            'val' => $_POST['email']
        ),
        2 => array(
            'text' => 'Phone',
            'val' => $_POST['phone']
        )
    );


    $message = "";
    foreach($fields as $field) {
        $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
    }


    $mail = new PHPMailer;

    $mail->IsSMTP(); // Set mailer to use SMTP
    $mail->SMTPDebug = 4; 


    $mail->Host = 'localhost';
    $mail->Port = 25;
    $mail->SMTPAuth = false;
    $mail->SMTPSecure = false;
    $mail->SMTPAutoTLS = false;
    $mail->SMTPSecure = false;



    $mail->From = $email;
    $mail->FromName = $fullname;
    $mail->AddAddress($to_address); 
    $mail->AddReplyTo($email, $fullname);


    $mail->IsHTML(true); // Set email format to HTML
    $mail->CharSet = 'UTF-8';

    $mail->Subject = $subjectline;
    $mail->Body    = $message;

    if($mail->Send()) {
        $result = array ('response'=>'success');
    } else {
        $result = array ('response'=>'error' , 'error_message'=> $mail->ErrorInfo);
    }

    echo json_encode($result);

} else {

    $result = array ('response'=>'error' , 'error_message'=>'Data has not been entered');
    echo json_encode($result);

}
?>

1 个答案:

答案 0 :(得分:0)

SMTPDebug = 4太吵了; 2就足够了。

这表示您使用的是旧版本,因此update

2016-12-22 12:12:45 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/)

无论如何,这是重要的一句话:

2016-12-22 12:12:45 SERVER -> CLIENT: 250 OK id=1cK2En-001yR0-3J

这表示该消息已成功接受。 PHPMailer的参与(以及任何其他邮件类)在此结束。接下来,您需要找出邮件的去向 - 首先检查您的垃圾邮件文件夹,然后请求GoDaddy支持人员帮助您跟踪邮件,因为他们不会让您看到邮件服务器日志。