我有一个可以在本地测试环境中发送电子邮件的PHP脚本。我正在使用Google SMTP服务器。但是当我使用相同的代码向Godaddy服务器发送电子邮件时,我没有收到任何电子邮件。
这是我正在使用的PHP代码
if (empty($errorMessage)) {
function smtpmailer($to, $from, $from_name, $subject, $body)
{
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->SMTPAutoTLS = false;
$mail->DKIM_domain = '127.0.0.1';
$mail->Debugoutput = 'html';
$mail->Host = 'localhost';
$mail->Port = 465;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if (!$mail->Send()) {
//$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
//$error = 'Message sent!';
return true;
}
}
if (smtpmailer("testuser@gmail.com", $email, $name, $subject, $message)) {
array_push($successMessage, "Message is send successfully");
} else {
array_push($mailErrorMessage, "Error sending your message, please try again");
}
}
这是我收到的错误消息
2017-08-18 08:59:00 SERVER -> CLIENT: 235 Authentication succeeded
2017-08-18 08:59:00 CLIENT -> SERVER: MAIL FROM:<sdfsdf@dfdsfds.com>
2017-08-18 08:59:00 SERVER -> CLIENT: 250 OK
2017-08-18 08:59:00 CLIENT -> SERVER: RCPT TO:<testuser@gmail.com>
2017-08-18 08:59:00 SERVER -> CLIENT: 250 Accepted
2017-08-18 08:59:00 CLIENT -> SERVER: DATA
2017-08-18 08:59:00 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2017-08-18 08:59:00 CLIENT -> SERVER: Date: Fri, 18 Aug 2017 08:59:00 +0000
2017-08-18 08:59:00 CLIENT -> SERVER: To: testuser@gmail.com
2017-08-18 08:59:00 CLIENT -> SERVER: From: sdfdsf <sdfsdf@dfdsfds.com>
2017-08-18 08:59:00 CLIENT -> SERVER: Subject: sdfdsf
2017-08-18 08:59:00 CLIENT -> SERVER: Message-ID: <07861decb0a3210648608f6e6b5db395@thedomain.com>
2017-08-18 08:59:00 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.24 (https://github.com/PHPMailer/PHPMailer)
2017-08-18 08:59:00 CLIENT -> SERVER: MIME-Version: 1.0
2017-08-18 08:59:00 CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
2017-08-18 08:59:00 CLIENT -> SERVER:
2017-08-18 08:59:00 CLIENT -> SERVER: dsfdfsf
2017-08-18 08:59:00 CLIENT -> SERVER:
2017-08-18 08:59:00 CLIENT -> SERVER: .
2017-08-18 08:59:00 SERVER -> CLIENT: 250 Message denied for spoofing attempt via SMTP Auth (From address: sdfdsf <sdfsdf@dfdsfds.com> IP: 127.0.0.1 AuthenticatedID: contact@thdeomain.com Account owner: theowner)
2017-08-18 08:59:00 CLIENT -> SERVER: QUIT
2017-08-18 08:59:00 SERVER -> CLIENT: 221 md-59.webhostbox.net closing connection
我不知道这是PHPMailer或邮件服务器的问题