TransWikia.com

Microsoft 365 SMTP authentication failure [SMTP: Invalid response code received from server

Stack Overflow Asked by Reel on November 22, 2021

i am getting following error but all settings are correct no issue but advice if someone has done smtp setting of 365 office

connectors are added in admin center and changed the max sp as advised

authentication failure [
    SMTP: Invalid response code received from server 
    (code: 535, response: 5.7.3 Authentication unsuccessful 
        [LO2P265CA0220.GBRP265.PROD.OUTLOOK.COM]
    )
]

here is code:

<?php
    require_once "Mail.php";

    $from = '<[email protected]>'; 
    $to = '<[email protected]>'; 
    $subject = 'Insert subject here'; 
    $body = "Hello world! this is the content of the email"; 

    $headers = array(
        'From' => $from,
        'To' => $to,
        'Subject' => $subject
    );

    $smtp = Mail::factory('smtp', array(
        'host' => 'smtp.office365.com', 
        'SMTPSecure' => 'tls',
        'port' => '587',
        'StartTLS' => true,
        'auth' => true,
        'username' => '[email protected]',
        'password' => '321password' 
    ));


    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
        echo '<p>'.$mail->getMessage().'</p>';
    } else {
        echo '<p>Message successfully sent!</p>';
    }
?>

One Answer

If you are very sure that all settings including Username and Password are correctly configured, then the problem is a Microsoft thing. And how to solve it is this;

you need to login from a browser (https://accounts.live.com) using the username and password you have configured in your application.

While logged in, go to "security and privacy" and look for the link to "recent activity" alternatively, you can just enter this address after logging in to go there directly https://account.live.com/Activity.

From here you should see the attempts from the email you are sending from and click the option "This was me" next/under to it.

Also consider disabling 2step authenticator if on.

When you have completed this, wait a few minutes and then try again.

Let me know if this worked. :)

Answered by mw509 on November 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP