Do your lines 81 to 87 of system/library/mail/smtp.php look like this?
Code: Select all
if (substr($this->smtp_hostname, 0, 3) == 'tls') {
$hostname = substr($this->smtp_hostname, 6);
} else {
$hostname = $this->smtp_hostname;
}
$handle = fsockopen($hostname, $this->smtp_port, $errno, $errstr, $this->smtp_timeout);
tls:// is not a scheme like ssl:// and as such OC strips that from the hostname before connecting.
It only uses the tls:// definition in the given hostname as an indication that it needs to issue a STARTTLS command later on.
So fsockopen(): unable to connect to tls://smtp.office365.com:587 (Network is unreachable) should not happen as it should connect to smtp.office365.com:587 not tls://smtp.office365.com:587, tls:// is not a thing.
Connection to smtp.office365.com:587 works just fine as below where only the authentication eventually fails of course.
Mail Test initiated by: xxxxx
Sending from: xxxxx@xxxxxxxxxx
Sending to: xxxxx@xxxxxxxxxx
2021-10-11 15:17:26 - Host resolve: smtp.office365.com->52.98.42.194
2021-10-11 15:17:26 - Connecting to smtp.office365.com at 587
2021-10-11 15:17:26 - socket status: OK
2021-10-11 15:17:26 - SEND: EHLO xxxxxxx
[15:17:26.587644] EHLO 250-HKAPR03CA0010.outlook.office365.com Hello [x.x.x.x]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
2021-10-11 15:17:26 - SEND: STARTTLS
[15:17:26.603244] STARTTLS 220 2.0.0 SMTP server ready
2021-10-11 15:17:26 - SEND: EHLO xxxxxxxxxxxxxxxxxxx
[15:17:26.697447] EHLO 250-HKAPR03CA0010.outlook.office365.com Hello [x.x.x.x]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN XOAUTH2
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
2021-10-11 15:17:26 - SEND: AUTH LOGIN
[15:17:26.713448] AUTH LOGIN 334 VXNlcm5hbWU6
2021-10-11 15:17:26 - SEND: XXXXXXXXXXXXXXXXX base64 username
[15:17:26.731449] base64 username 334 UGFzc3dvcmQ6
2021-10-11 15:17:26 - SEND: XXXXXXXXXXXXXXX base64 password
[15:17:31.751736] base64 password 535 5.7.3 Authentication unsuccessful [HKAPR03CA0010.apcprd03.prod.outlook.com]
535 5.7.3 Authentication unsuccessful [HKAPR03CA0010.apcprd03.prod.outlook.com]
Error: Password not accepted from server
SEND TEST MAIL FAILED