0

When trying to get all mails from mailbox I got this error:

Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/tls}INBOX in C:\xampp\htdocs\Phpimapdoc\index.php on line 8
Cannot connect to Outlook: [CLOSED] IMAP connection broken (server response)

My code is

/* connect to outlook */
$hostname = '{outlook.office365.com:993/imap/tls}INBOX';
$username = 'mailid@outlook.com';
$password = 'password123';

/* try to connect */
$inbox = imap_open($hostname,$username,$password, NULL, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI')) or die('Cannot connect to Outlook: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');
/* connect to outlook */
$hostname = '{outlook.office365.com:993/imap/tls}INBOX';
$username = 'mailid@outlook.com';
$password = 'password123';

/* try to connect */
$inbox = imap_open($hostname,$username,$password, NULL, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI')) or die('Cannot connect to Outlook: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');

The output has to stream all my outlook mails

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Sreekanth
  • 1
  • 2

0 Answers0