我试图通过PHPMailer发送电子邮件。出于某种原因,我不明白认证失败了。
我也尝试了不同的设置,比如将设置验证设置为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
任何想法?
答案 0 :(得分:0)
经过一些研究后我发现,这实际上是一个cPanel问题!似乎cPanel正在将传出SMTP连接重定向到自己的本地邮件服务器。
中可以禁用此选项主页»服务器配置»调整设置
在cPanel根面板中。 我只是没想到,因为我看到服务器响应。我只是没有意识到,它是自己的Web服务器邮件服务器,正在响应