Page 1 of 1

Setup office365 mail server in Opencart 3.0.2

Posted: Wed Nov 15, 2017 11:17 am
by jaychoo
Hi,

I tried setting up Office365 in Opencart but met with internal error. May I know if anyone managed to solve this? I tried with gmail its working.

below is the setting i use for Office365

mail protocol : SMTP
mail parameter : blank
smtp hostname : ssl://smtp.office365.com
smtp username : user@example.com
smtp password : password
smtp port : 587
smtp timeout : 5

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Wed Nov 15, 2017 12:46 pm
by straightlight
Followed is a documentation on how to setup Office 365 emails as multifunction: https://support.office.com/en-us/articl ... 05d654b4c4 . See the table beginning with: Device or Application setting and value.

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Wed Nov 11, 2020 7:28 pm
by Choicecloud
Office 365 uses TLS.
In the SMTP server : tls://smtp.office365.com

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Thu Oct 07, 2021 5:36 am
by rivanoo
hello both ssl or tls not work i get error

error
<b>Warning</b>: fsockopen(): unable to connect to tls://smtp.office365.com:587 (Network is unreachable) in <b>/home/ admin/domains/wowmart.cn/public_html/system/library/mail/ smtp.php</b> on line <b>87</b>

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Thu Oct 07, 2021 4:14 pm
by ADD Creative
(Network is unreachable) suggests a network issue. Contact your host, maybe they block outgoing mail.

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Mon Oct 11, 2021 9:32 am
by xyzmetehan
U must use SSL Port (465)

587 for TLS

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Tue Oct 12, 2021 1:11 am
by straightlight
xyzmetehan wrote:
Mon Oct 11, 2021 9:32 am
U must use SSL Port (465)

587 for TLS
Choicecloud wrote:
Wed Nov 11, 2020 7:28 pm
Office 365 uses TLS.
In the SMTP server : tls://smtp.office365.com

Re: Setup office365 mail server in Opencart 3.0.2

Posted: Tue Oct 12, 2021 2:04 am
by by mona
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