我有一個phpmailer的問題,我的本地主機上的一切都很好,我從我的PHP應用程序獲取郵件,但是當我在我的臨時使用相同的碼頭容器時環境中,PHPMailer的回報成功,但我得到了我的郵箱裏沒有郵件了:/PHPMailer在本地主機上工作,而不是在分期上,同樣的配置都在
下面是一些代碼:
//create an instance of PHPMailer
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host='ssl0.ovh.net';
$mail->Port = 465;
$mail->Username = '[email protected]';
$mail->Password = 'mypassword';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Priority = 3;
$mail->CharSet = "ISO-8859-1"; //ISO-8859-1 _ utf-8
$mail->setFrom('[email protected]');
$mail->AddAddress('[email protected]');
$mail->Subject='New mail';
$mail->Body = "
Name: " . $_POST['inputName'] . "\r\n
Mail : " . $_POST['inputEmail'] . "\r\n
Message: \r\n\r\n" . stripslashes($_POST['inputMessage']);
$mail->SmtpClose();
if(!$mail->send()) {
$data = array('success' => false, 'message' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo);
echo json_encode($data);
exit;
}
$data = array('success' => true, 'message' => 'Thanks! We have received your message.');
echo json_encode($data);
這裏是我的服務器上的響應:
2017-08-09 07:37:48 CLIENT -> SERVER: EHLO staging.thomasmorice.com
2017-08-09 07:37:48 CLIENT -> SERVER: AUTH LOGIN
2017-08-09 07:37:48 CLIENT -> SERVER: aGD76QHRob21hc21efmljZSaajb20=
2017-08-09 07:37:48 CLIENT -> SERVER: QnhuNnJDWW5lOp8A
2017-08-09 07:37:48 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2017-08-09 07:37:48 CLIENT -> SERVER: RCPT TO:<[email protected]>
2017-08-09 07:37:48 CLIENT -> SERVER: DATA
2017-08-09 07:37:48 CLIENT -> SERVER: Date: Wed, 9 Aug 2017 07:37:48 +0000
2017-08-09 07:37:48 CLIENT -> SERVER: To: [email protected]
2017-08-09 07:37:48 CLIENT -> SERVER: From: [email protected]
2017-08-09 07:37:48 CLIENT -> SERVER: Subject: New mail
2017-08-09 07:37:48 CLIENT -> SERVER: Message-ID:<[email protected]>
2017-08-09 07:37:48 CLIENT -> SERVER: X-Priority: 3
2017-08-09 07:37:48 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
2017-08-09 07:37:48 CLIENT -> SERVER: MIME-Version: 1.0
2017-08-09 07:37:48 CLIENT -> SERVER: Content-Type: text/plain; charset=ISO-8859-1
2017-08-09 07:37:48 CLIENT -> SERVER:
2017-08-09 07:37:48 CLIENT -> SERVER:
2017-08-09 07:37:48 CLIENT -> SERVER: Name: thomas test mail
2017-08-09 07:37:48 CLIENT -> SERVER:
2017-08-09 07:37:48 CLIENT -> SERVER: Mail : [email protected]
2017-08-09 07:37:48 CLIENT -> SERVER:
2017-08-09 07:37:48 CLIENT -> SERVER: Message:
2017-08-09 07:37:48 CLIENT -> SERVER:
2017-08-09 07:37:48 CLIENT -> SERVER: test mail
2017-08-09 07:37:48 CLIENT -> SERVER:
2017-08-09 07:37:48 CLIENT -> SERVER: .
2017-08-09 07:37:48 CLIENT -> SERVER: QUIT
{"success":true,"message":"Thanks! We have received your message."}
我真的被困在這個,因爲我有完全相同的配置本地主機和服務器碼頭容器) 也許是因爲我的MX在DNS?我迷路了有人有線索嗎?
非常感謝您的幫助
- 編輯
事情經過一番研究,怪異,使用this website測試MX查找與MX的工具,我看到,當我運行測試與本地服務器:thomasmorice.dev,我得到一個DNS記錄發現:/這怎麼可能,因爲這是我的本地服務器:/ 做同樣的staging.thomasmorice.com,我得到一個DNS錯誤..在我看來這應該是反過來..我真的很困惑
不知道它是否重要,但您在發送電子郵件之前關閉了SMTP連接? '$ mail-> SmtpClose();' – Matt
噢,這很奇怪,我不得不承認:/ 我已經刪除了這行......但仍然有相同的問題:/ –
您可以嘗試閱讀[PHPMailer疑難解答指南] (https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)。如果你設置了'SMTPDebug = 2',你會看到服務器在說什麼。另外,您需要更新PHPMailer。 – Synchro