I have gone through the settings and the available documentation but I just can’t see to get OAuth2 and Office365 to work together. Any pointers would be greatly appreciated.
@ahefner-chr Try enabling debugging for the IMAP2 plugin as described at plugin:imap2 [phpList Resources]
I have updated the config to turn on IMAP debugging as suggested from the instructions on the documentation.
config.php has the following
$bounce_mailbox_port = '993/imap/ssl/debug';
$log_options = [
'threshold' => 'DEBUG',
'dir' => '/tmp/imap/',
];
I also checked to make sure that /tmp/imap is writeable by www-data
drwxr-xr-x 2 www-data www-data 4096 Jul 25 16:02 imap
No log file or debugging information is written to the directory.
@ahefner-chr I don’t really know. With these settings I can connect to the mailbox
$bounce_mailbox_host = 'outlook.office365.com';
$bounce_mailbox_port = '993/imap/ssl/debug';
I think that “unknown reason” in the error message might mean there is something basic not working. Try making this code change to display errors when trying to open a socket
file plugins/Imap2/vendor/javanile/php-imap2/src/Roundcube/ImapClient.php
line 1062 is
$this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, $this->prefs['timeout']);
remove the ‘@’ character. Any error might then be shown in the php error log or to the screen similarly to those in your earlier screenshot.
I get the following when running from the commandline. The web interface had the same information as the screenshot that was previously submitted.
sudo php /var/www/lists/admin/index.php -p processbouncesoauth2 -m OAuth2 -c /var/www/lists/config/config.php
[sudo] password for xxxxxxxxx:
PHP Warning: Undefined array key "HTTP_HOST" in /var/www/lists/admin/init.php on line 621
phpList - phpList version 3.6.16 (c) 2000-2025 phpList Ltd, https://www.phplist.com
PHP Warning: fsockopen(): SSL: Connection reset by peer in /var/www/lists/admin/plugins/Imap2/vendor/javanile/php-imap2/src/Roundcube/ImapClient.php on line 1063
PHP Warning: fsockopen(): Failed to enable crypto in /var/www/lists/admin/plugins/Imap2/vendor/javanile/php-imap2/src/Roundcube/ImapClient.php on line 1063
PHP Warning: fsockopen(): Unable to connect to ssl://outlook.office365.com:993 (Unknown error) in /var/www/lists/admin/plugins/Imap2/vendor/javanile/php-imap2/src/Roundcube/ImapClient.php on line 1063
PHP Warning: imap2_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl/debug}INBOX in /var/www/lists/admin/plugins/OAuth2/processbouncesoauth2.php on line 47. Source code in /var/www/lists/admin/plugins/Imap2/Connection.php on line 32
phpList - Cannot create POP3 connection to {outlook.office365.com:993/imap/ssl/debug}INBOX: Can not authenticate to IMAP server: Could not connect to ssl://outlook.office365.com:993: Unknown reason
phpList - Download failed, exiting
Web interface results…
@ahefner-chr It looks like you might not have ssl set-up correctly, but I don’t know much about that. Probably need to raise the problem with whoever administers your system.
You could try connecting without using php, from a command line try, which might confirm whether it is a problem with php and ssl or ssl in general
openssl s_client -connect outlook.office365.com:993
From the server I get
openssl s_client -connect outlook.office365.com:993
CONNECTED(00000003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 323 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---
from my desktop client I get
openssl s_client -connect outlook.office365.com:993
CONNECTED(00000003)
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, CN = DigiCert Cloud Services CA-1
verify return:1
depth=0 C = US, ST = Washington, L = Redmond, O = Microsoft Corporation, CN = outlook.com
verify return:1
---
Certificate chain
0 s:C = US, ST = Washington, L = Redmond, O = Microsoft Corporation, CN = outlook.com
i:C = US, O = DigiCert Inc, CN = DigiCert Cloud Services CA-1
a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256
v:NotBefore: Mar 29 00:00:00 2025 GMT; NotAfter: Mar 28 23:59:59 2026 GMT
1 s:C = US, O = DigiCert Inc, CN = DigiCert Cloud Services CA-1
i:C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256
v:NotBefore: Sep 25 00:00:00 2020 GMT; NotAfter: Sep 24 23:59:59 2030 GMT
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIIpzCCB4+gAwIBAgI continuation of certificate....
I am wondering if there is a network firewall issue that is closing that connection. I will reach out to my network team and see what we can find and will update with any findings.
We finally discovered the issue was that our network firewall was blocking / filtering the handshake to the imap service.