Muszę skonfigurować PHPMailer'a tak aby do wysyłki używał konta outlook.
Poniżej kod:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.office365.com";
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPDebug = 4;
$mail->AuthType = 'LOGIN';
$mail->SMTPAuth = true;
$mail->Username = "xxx@xxx.pl";
$mail->Password = 'pass';
$mail->From = 'xxx@xxx.pl';
$mail->FromName = 'XXX';
$mail->AddAddress('yyy@yyy.pl', 'Test');
$mail->CharSet = 'UTF-8';
$mail->IsHTML(true);
$mail->Subject = 'Test subject';
$mail->Body = 'Body <br>Test <strong>HTML tag</strong>';
$mail->AltBody = 'xyz';
if(!$mail->Send()){
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
Niestety całość kończy się niepowodzeniem:
2023-07-03 15:51:50 Auth method requested: LOGIN
2023-07-03 15:51:50 Auth methods available on the server: LOGIN,XOAUTH2
2023-07-03 15:51:50 CLIENT -> SERVER: AUTH LOGIN
2023-07-03 15:51:50 SMTP INBOUND: "334 eVXNlcXm5hbWUT6"
2023-07-03 15:51:50 SERVER -> CLIENT: 334 eVXNlcXm5hbWUT6
2023-07-03 15:51:50 CLIENT -> SERVER: bccxcnR5QGdsb2JhbHN5c3RlbS5jb20ucGw=
2023-07-03 15:51:50 SMTP INBOUND: "334 UGFdd311cqQ6"
2023-07-03 15:51:50 SERVER -> CLIENT: 334 UGFdd311cqQ6
2023-07-03 15:51:50 CLIENT -> SERVER: Qe3VzxxE5MDQs=
2023-07-03 15:51:59 SMTP INBOUND: "535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [FR3P281CA0015.DEUP281.PROD.OUTLOOK.COM 2023-07-03T15:51:59.281Z 018DB7A9266F6B2134B]"
2023-07-03 15:51:59 SERVER -> CLIENT: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [FR3P281CA0015.DEUP281.PROD.OUTLOOK.COM 2023-07-03T15:51:59.281Z 018DB7A9266F6B2134B]
2023-07-03 15:51:59 SMTP ERROR: Password command failed: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [FR3P281CA0015.DEUP281.PROD.OUTLOOK.COM 2023-07-03T15:51:59.281Z 018DB7A9266F6B2134B]
SMTP Error: Could not authenticate.
2023-07-03 15:51:59 CLIENT -> SERVER: QUIT
2023-07-03 15:51:59 SMTP INBOUND: "221 2.0.0 Service closing transmission channel"
2023-07-03 15:51:59 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
2023-07-03 15:51:59 Connection: closed
Czy da się to zrobić nie korzystając z XOAUTH2?