Jump to content

Recommended Posts

Been trying to get a script to parse an office365 inbox with no success.  I've tried out stackoverflow / google search recommendations, but no luck

<?php

        $user = '[email protected]';
        $pass = 'fakepass';
        $hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX';
        $m = imap_open($hostname, $user, $pass, NULL, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));

When using real creds in the above test script, I get the following error.

Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX in /private/tmp/imap.php on line 5
PHP Notice:  Unknown: Can not authenticate to IMAP server: AUTHENTICATE failed. (errflg=2) in Unknown on line 0

I've tried both php 5.6.30 and php 7.1.4 on CentOS 6.5 and on MacOSX.  I've checked my SSL settings as well and they're all appear to be set properly.

 

This has been driving me nuts for the last few days.  If anyone knows what's going on here, it'd be greatly appreciated.  

 

Nick

Link to comment
https://forums.phpfreaks.com/topic/303797-imap_open-outlookoffice365com-failures/
Share on other sites

just a stab here but my connection string does not have an 'imap' in it.

 

$host = "{". $domain . ":993/ssl/novalidate-cert}";
$mailbox = imap_open($host.'INBOX', $incoming_email, $emlaccess);

 

where domain is simply name.com, etc.

incoming email is the mailbox name, ie, [email protected]

emlaccess is the mailbox password.

Edited by ginerjm

Been trying to get a script to parse an office365 inbox with no success.  I've tried out stackoverflow / google search recommendations, but no luck

<?php

        $user = '[email protected]';
        $pass = 'fakepass';
        $hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX';
        $m = imap_open($hostname, $user, $pass, NULL, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));

When using real creds in the above test script, I get the following error.

Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX in /private/tmp/imap.php on line 5
PHP Notice:  Unknown: Can not authenticate to IMAP server: AUTHENTICATE failed. (errflg=2) in Unknown on line 0

I've tried both php 5.6.30 and php 7.1.4 on CentOS 6.5 and on MacOSX.  I've checked my SSL settings as well and they're all appear to be set properly.

 

This has been driving me nuts for the last few days.  If anyone knows what's going on here, it'd be greatly appreciated.  

 

Nick

Try adding [email protected] to the host

Try adding [email protected] to the host

 

I tried that as well.  It produces the same error.  :(  Thanks for replying though.

 

I still haven't ruled out something weird on the server side.  This is not a shared account (according to the sysadmin who's managing our account) so not sure what else there is to check on the server side settings.

just a stab here but my connection string does not have an 'imap' in it.

 

$host = "{". $domain . ":993/ssl/novalidate-cert}";
$mailbox = imap_open($host.'INBOX', $incoming_email, $emlaccess);

 

where domain is simply name.com, etc.

incoming email is the mailbox name, ie, [email protected]

emlaccess is the mailbox password.

 

 

Interesting, and this works for you?  What version of PHP and OS are you on?  If this is working for you, then I'm going to go back to my sysadmin and say this is an email server setting issue and not this script.

Btw, it turned out there is an internal whitelist that needed to be updated.  Due to the fact this node is in AWS and it was recently relaunched, the new public IP was not whitelisted.

 

Solution for us : associate elastic IP to node.  Whitelist ElasticIP within Office365 system.   Btw, since telnet to the port 993 from the affected host was still working, we did not initially think this was an IP whitelist issue.

 

The PHP code posted above worked as it should.  Thank you for everyone for chiming in.

 

Nick

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.