PHPMAILER邮件已发送但未收到

时间:2015-05-14 08:27:31

标签: email phpmailer

我正在尝试使用PHPMailer,但我遇到了问题。这是我的测试代码:

<?php

require './PHPMailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->isSMTP();

$mail->SMTPDebug = 4;

$mail->Debugoutput = 'html';

$mail->Host = "localhost";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;

$mail->SMTPAuth = true;

$mail->Username = "donotreply@myservermail";

$mail->Password = "mypassword";

$mail->setFrom('donotreply@myservermail', 'Mail test');

$mail->addReplyTo('myemail@live.com', 'First Last');

$mail->addAddress('donotreply@myservermail', 'Test mail');

$mail->Subject = 'PHPMailer SMTP test';


$mail->msg = 'Hello there this is a test . ';

$mail->Body = 'This is a plain-text message body';

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

?>

这是浏览器的结果,我看到没有错误:

Connection: opening to localhost:25, timeout=300, options=array ()
Connection: opened
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 localhost ESMTP"
SMTP -> get_lines(): $data is "220 localhost ESMTP"
SERVER -> CLIENT: 220 localhost ESMTP
CLIENT -> SERVER: EHLO MY_SERVER_NAME
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-localhost"
SMTP -> get_lines(): $data is "250-localhost"
SMTP -> get_lines(): $data was "250-localhost"
SMTP -> get_lines(): $str is "250-SIZE 20480000"
SMTP -> get_lines(): $data is "250-localhost250-SIZE 20480000"
SMTP -> get_lines(): $data was "250-localhost250-SIZE 20480000"
SMTP -> get_lines(): $str is "250-AUTH LOGIN"
SMTP -> get_lines(): $data is "250-localhost250-SIZE 20480000250-AUTH LOGIN"
SMTP -> get_lines(): $data was "250-localhost250-SIZE 20480000250-AUTH LOGIN"
SMTP -> get_lines(): $str is "250 HELP"
SMTP -> get_lines(): $data is "250-localhost250-SIZE 20480000250-AUTH LOGIN250 HELP"
SERVER -> CLIENT: 250-localhost250-SIZE 20480000250-AUTH LOGIN250 HELP
Auth method requested: UNKNOWN
Auth methods available on the server: LOGIN
Auth method selected: LOGIN
CLIENT -> SERVER: AUTH LOGIN
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 SOME_ENCRYPTED_STRING"
SMTP -> get_lines(): $data is "334 SOME_ENCRYPTED_STRING"
SERVER -> CLIENT: 334 SOME_ENCRYPTED_STRING
CLIENT -> SERVER: SOME_ENCRYPTED_STRING
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 SOME_ENCRYPTED_STRING"
SMTP -> get_lines(): $data is "334 SOME_ENCRYPTED_STRING"
SERVER -> CLIENT: 334 SOME_ENCRYPTED_STRING
CLIENT -> SERVER: SOME_ENCRYPTED_STRING
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "235 authenticated."
SMTP -> get_lines(): $data is "235 authenticated."
SERVER -> CLIENT: 235 authenticated.
CLIENT -> SERVER: MAIL FROM:<donotreply@MY_SERVER_MAIL>
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 OK"
SMTP -> get_lines(): $data is "250 OK"
SERVER -> CLIENT: 250 OK
CLIENT -> SERVER: RCPT TO:<MY_EMAIL@yahoo.com>
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 OK"
SMTP -> get_lines(): $data is "250 OK"
SERVER -> CLIENT: 250 OK
CLIENT -> SERVER: DATA
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "354 OK, send."
SMTP -> get_lines(): $data is "354 OK, send."
SERVER -> CLIENT: 354 OK, send.
CLIENT -> SERVER: Date: Thu, 14 May 2015 10:40:00 +0200
CLIENT -> SERVER: To: MY_EMAIL yahoo <MY_EMAIL@yahoo.com>
CLIENT -> SERVER: From: MAIL_SERVER test <donotreply@MY_SERVER_MAIL>
CLIENT -> SERVER: Reply-To: MY_EMAIL Live <MY_EMAIL@live.com>
CLIENT -> SERVER: Subject: PHPMailer SMTP test
CLIENT -> SERVER: Message-ID: <SOME_ENCRYPED_STRING@MY_SERVER_NAME>
CLIENT -> SERVER: X-Priority: 3
CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/)
CLIENT -> SERVER: MIME-Version: 1.0
CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
CLIENT -> SERVER:
CLIENT -> SERVER: This is a plain-text message body
CLIENT -> SERVER:
CLIENT -> SERVER: .
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 Queued (0.000 seconds)"
SMTP -> get_lines(): $data is "250 Queued (0.000 seconds)"
SERVER -> CLIENT: 250 Queued (0.000 seconds)
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "221 goodbye"
SMTP -> get_lines(): $data is "221 goodbye"
SERVER -> CLIENT: 221 goodbye
Connection: closed
Message sent!

我已尝试使用不同的电子邮件,yahoo,gmail等进行此测试,但仍然相同。我还仔细检查了所有电子邮件的垃圾邮件,几个小时 有什么想法吗?

1 个答案:

答案 0 :(得分:1)

成功 - 在向localhost传递时,正如您要求的那样。之后发生的事情完全在PHPMailer的控制范围之外。您需要查看本地邮件服务器的日志以查看之后会发生什么,但看起来它没有得到更多,所以您需要查看您的邮件服务器&#39; s配置。