0
我試圖通過PHPMailer發送電子郵件。由於某種原因,我不明白認證失敗。PHPMailer Exchange Auth
我也試過不同的事情,比如設置認證到PLAIN和安全方法到TLS,但它似乎沒有幫助。
我們的Exchange有一個發送連接器,它將電子郵件發送到我們的垃圾郵件代理服務器,郵件代理服務器將郵件發送到郵件服務器,郵件服務器使用DKIM加密郵件。
這是我的代碼:
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $settings['mailserver']; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Port = "25";
$mail->Username = $settings['mail_domain']."\\".$settings['mail_username']; // SMTP username
echo $mail->Username;
$mail->Password = $settings['mail_password']; // SMTP password
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPDebug = 2;
$mail->From = $settings['mail_sender'];
$mail->AddAddress($emp_mail); // name is optional
$mail->AddReplyTo($settings['mail_sender']);
$mail->WordWrap = 50; // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Neue Datei erhalten: ".$filename." - ".$_COOKIE['settings']['firmenname'];
$mail->Body = $text;
$mail->AltBody = "Bitte laden Sie diese Email in der HTML Ansicht";
if(!$mail->Send())
{
$return_code['Code'] = 500;
$return_code['Msg'] = $mail->ErrorInfo.print_r($settings);
}else{
$return_code['Code'] = "200";
}
這就是我的回答:
2016-09-26 13:39:44 SERVER -> CLIENT: 220-cpanel-1.fr-hostings.at ESMTP Exim 4.87 #1 Mon, 26 Sep 2016 15:39:44 +0200
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
2016-09-26 13:39:44 CLIENT -> SERVER: EHLO transfer.feurich.com
2016-09-26 13:39:44 SERVER -> CLIENT: 250-cpanel-1.fr-hostings.at Hello cpanel-1.fr-hostings.at [92.222.157.38]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
2016-09-26 13:39:44 CLIENT -> SERVER: STARTTLS
2016-09-26 13:39:44 SERVER -> CLIENT: 220 TLS go ahead
2016-09-26 13:39:44 CLIENT -> SERVER: EHLO transfer.feurich.com
2016-09-26 13:39:44 SERVER -> CLIENT: 250-cpanel-1.fr-hostings.at Hello cpanel-1.fr-hostings.at [92.222.157.38]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP
2016-09-26 13:39:44 CLIENT -> SERVER: AUTH LOGIN
2016-09-26 13:39:44 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2016-09-26 13:39:44 CLIENT -> SERVER: xxx=
2016-09-26 13:39:46 SERVER -> CLIENT: 535 Incorrect authentication data
2016-09-26 13:39:46 SMTP ERROR: Username command failed: 535 Incorrect authentication data
2016-09-26 13:39:46 SMTP Error: Could not authenticate.
2016-09-26 13:39:46 CLIENT -> SERVER: QUIT
2016-09-26 13:39:46 SERVER -> CLIENT: 221 cpanel-1.fr-hostings.at closing connection
2016-09-26 13:39:46 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
什麼想法?
這在PHPMailer疑難解答指南中涵蓋從錯誤 - 確保您連接到的服務器是你認爲它的一個是。這就是爲什麼保持打開TLS證書驗證非常重要的原因,因爲它會檢測到這種情況。 – Synchro