0
我有一個PHPMailer的問題,我想連接到一個配置了我的網站IP的Office 365服務器,這裏有一個連接器,因此我可以連接到Office 365 SMTP服務器來進行連接而無需身份驗證,因爲我的IP地址是列入白名單。如何使用PHPMailer連接到Office 365?
問題是我無法對服務器進行身份驗證。
PHPMailer的輸出:
2016-11-23 09:06:50 CLIENT -> SERVER: EHLO www.thuis*******.nl 2016-11-23 09:06:50 SMTP Error: Could not authenticate. 2016-11-23 09:06:50 CLIENT -> SERVER: QUIT 2016-11-23 09:06:50 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
PHP文件:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = '';
$mail->SMTPAutoTLS = false;
$mail->Host = "thuis*******-nl.mail.protection.outlook.com";
$mail->Port = 25;
$mail->SetFrom('[email protected]*******.nl', 'John');
$mail->AddReplyTo("[email protected]*******.nl");
$mail->Subject = "This is the subject";
$mail->MsgHTML('Message body');
$address = "[email protected]";
$mail->AddAddress($address);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
您已經將您的代碼基於一個過時的示例,因此請確保您使用的是最新版本。如果您閱讀錯誤消息指出的文檔,它也會有所幫助。 – Synchro
@Synchro謝謝你,我找到了解決方案,你可以在下面閱讀。 –