1

imap_open in php suddenly stopped working reading office 365 mail box from 15 Oct 2022. Talked to a Vendor of Office 365. He adviced to use TLS 1.2. But I have no idea how to use TLS 1.2 in my code.

How to incorporate TLS 1.2 in the code? The error I am getting is as below:

Can not authenticate to IMAP server: AUTHENTICATE failed.

$username =  $row->email;
$password =  $row->password;

$mailbox = "{outlook.office365.com:993/imap/ssl/authuser=$username}";
$inbox = imap_open($mailbox, $username, $password);


if (!$inbox){
    print imap_last_error();      
}
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
kumarsunit
  • 11
  • 1
  • Do you read the manual of imap_open function...? [here](https://www.php.net/manual/en/function.imap-open.php). There are examples with SSL it seems to me not ..? To see maybe..? – Juan Nov 04 '22 at 15:06
  • Note: Microsoft is discontinuing basic authentication for IMAP connections . Check `Oauth IMAP` application (e.g. `https://www.php-imap.com/examples/oauth` ) – Ken Lee Nov 04 '22 at 15:12
  • This is what @KenLee was referring to: https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online and it seems there's way to enable the old way back until the end of year. – James Z Nov 04 '22 at 15:47
  • Thanks everyone for the reply. But can anyone give idea of the changes that need to be done in the code that I have posted above. – kumarsunit Nov 04 '22 at 17:43

0 Answers0