Send email via PHP PHPMailer

Free Will 0 Reputation points
2025-02-06T11:52:59.5866667+00:00

Greetings,

I made a question here https://answers.microsoft.com/en-us/msoffice/forum/all/send-email-via-php-phpmailer/f52ebcad-cc3b-4e2d-8afc-d173a8606f27, and they sent me here.

[quote]

I was trying to send emails via PHP using PHPMailer,

I added the App password or something like that, it worked with gmail.com, but here it does not work

$mail->CharSet = "UTF-8";

$mail->SMTPDebug = 2;

$mail->isSMTP();

$myEmail = "...@hotmail.com";

$myAppPassword = "...";

$mail->Host = 'smtp.office365.com';

$mail->SMTPAuth = true;

$mail->Username = $myEmail;

$mail->Password = $myAppPassword;

$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;

$mail->Port = 587;

result:

2025-02-05 23:00:38 SERVER -> CLIENT: 220 SJ0PR03CA0050.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 5 Feb 2025 23:00:38 +0000 [08DD45C3F467B4D2] 2025-02-05 23:00:38 CLIENT -> SERVER: EHLO ***********.net 2025-02-05 23:00:38 SERVER -> CLIENT: 250-SJ0PR03CA0050.outlook.office365.com Hello [2a02:4780:b:873:0:f47:f742:9]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8 2025-02-05 23:00:38 CLIENT -> SERVER: STARTTLS 2025-02-05 23:00:38 SERVER -> CLIENT: 220 2.0.0 SMTP server ready 2025-02-05 23:00:38 CLIENT -> SERVER: EHLO ***********.net 2025-02-05 23:00:38 SERVER -> CLIENT: 250-SJ0PR03CA0050.outlook.office365.com Hello [2a02:4780:b:873:0:f47:f742:9]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8 2025-02-05 23:00:38 CLIENT -> SERVER: AUTH LOGIN 2025-02-05 23:00:38 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2025-02-05 23:00:38 CLIENT -> SERVER: [credentials hidden] 2025-02-05 23:00:38 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2025-02-05 23:00:38 CLIENT -> SERVER: [credentials hidden] 2025-02-05 23:00:45 SERVER -> CLIENT: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [SJ0PR03CA0050.namprd03.prod.outlook.com 2025-02-05T23:00:45.731Z 08DD45C3F467B4D2] 2025-02-05 23:00:45 SMTP ERROR: Password command failed: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [SJ0PR03CA0050.namprd03.prod.outlook.com 2025-02-05T23:00:45.731Z 08DD45C3F467B4D2] SMTP Error: Could not authenticate. 2025-02-05 23:00:45 CLIENT -> SERVER: QUIT 2025-02-05 23:00:45 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel SMTP Error: Could not authenticate. El mensaje no pudo ser enviado. Error de Mailer: SMTP Error: Could not authenticate.

[/quote]

Would you know how to solve it?

Thank you in advance,

Regards

Windows for business Windows Client for IT Pros Directory services Active Directory
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.