Not able to Sync my Outlook mail server to my localhost server using imap_open

108 views Asked by At

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 = '[email protected]';
$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 = '[email protected]';
$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

0

There are 0 answers