Post by psytanium » Fri Jul 25, 2025 9:19 pm

Hi,

I’m trying to send notification emails using an Office 365 SMTP account, but I keep getting an error every time I confirm a purchase on the checkout page. Please see the attached screenshot of the error message.

I’ve also attached a screenshot of my OpenCart mail settings configuration.

I’ve double-checked that the username and password are correct by logging in directly at outlook.com, so the credentials work. Also I tried port 465 and SSL://

Has anyone faced this before? Any ideas what I might be missing?

Im using OC3.0.3.8

Thank you!

Attachments

???
smtp-settings.png
???
smpt-error.png
Last edited by psytanium on Sat Jul 26, 2025 12:08 am, edited 1 time in total.

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by khnaz35 » Fri Jul 25, 2025 10:16 pm

What is your opencart version?

btw you can do something like this to get more details on Exception
system/library/mail/smtp.php

Code: Select all

throw new \Exception('Error: EHLO not accepted from server'."\n".'['.$reply.']');

Got a burning question at 3 AM that even Google shrugs at? There’s a not-so-secret inbox that might just have your answer: khnaz35@gmail.com
Breathe in some nature while you're at it. It’s cheaper than therapy. :-*

Feel free to sling a bear my way via PayPal @ khnaz35@gmail.com


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by psytanium » Sat Jul 26, 2025 2:53 pm

I want to know if my SMTP configuration is correct or missing something. Thanks

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by psytanium » Sat Jul 26, 2025 3:10 pm

khnaz35 wrote:
Fri Jul 25, 2025 10:16 pm
What is your opencart version?

btw you can do something like this to get more details on Exception
system/library/mail/smtp.php

Code: Select all

throw new \Exception('Error: EHLO not accepted from server'."\n".'['.$reply.']');
Where do i add / replace this line of code ? Im using Opencart 3.0.8.0

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by paulfeakins » Mon Jul 28, 2025 9:29 pm

psytanium wrote:
Sat Jul 26, 2025 3:10 pm
Im using Opencart 3.0.8.0
There is no such version?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by psytanium » Tue Jul 29, 2025 8:49 pm

paulfeakins wrote:
Mon Jul 28, 2025 9:29 pm
psytanium wrote:
Sat Jul 26, 2025 3:10 pm
Im using Opencart 3.0.8.0
There is no such version?
Sorry, this :
Version 3.0.3.8

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by paulfeakins » Wed Jul 30, 2025 5:48 pm

psytanium wrote:
Sat Jul 26, 2025 3:10 pm

Code: Select all

throw new \Exception('Error: EHLO not accepted from server'."\n".'['.$reply.']');
This has been answered many times before: viewtopic.php?t=231301

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by psytanium » Fri Aug 08, 2025 3:15 am

paulfeakins wrote:
Wed Jul 30, 2025 5:48 pm
psytanium wrote:
Sat Jul 26, 2025 3:10 pm

Code: Select all

throw new \Exception('Error: EHLO not accepted from server'."\n".'['.$reply.']');
This has been answered many times before: viewtopic.php?t=231301
Thank you for your reply. Ill try that

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by psytanium » Sat Aug 23, 2025 3:49 pm

Why I can't post in the forum ? It says I have been blocked

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by psytanium » Sat Aug 23, 2025 3:50 pm

I changed the smtp.php to:

Code: Select all

if (substr($reply, 0, 3) != 250) {
				throw new \Exception('Error: EHLO not accepted from server!');
			}

			if (substr($this->smtp_hostname, 0, 3) == 'tls') {
				fputs($handle, 'STARTTLS' . "\r\n");

				$this->handleReply($handle, 220, 'Error: STARTTLS not accepted from server!');

				if (stream_socket_enable_crypto($handle, true, STREAM_CRYPTO_METHOD_TLS_CLIENT) !== true) {
					throw new \Exception('Error: TLS could not be established!');
				}

				fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . "\r\n");

				$this->handleReply($handle, 250, 'Error: EHLO not accepted from server!');
			}
I didn't add this line, because I don't know where should I add :

Code: Select all

throw new \Exception('Error: EHLO 1 not accepted from server!');

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by psytanium » Sat Aug 23, 2025 3:50 pm

When I checkout or anything that trigger sending our emails, I got this error:

Code: Select all

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
parsererror
<br />
<b>Fatal error</b>:  Uncaught Exception: Error:  (0) in /home/user/public_html/system/library/mail/smtp.php:91
Stack trace:
#0 /home/user/public_html/system/library/mail.php(142): Mail\Smtp-&gt;send()
#1 /home/user/storage/modification/catalog/controller/mail/order.php(302): Mail-&gt;send()
#2 /home/user/storage/modification/catalog/controller/mail/order.php(34): ControllerMailOrder-&gt;add(Array, '1', '', '')
#3 /home/user/storage/modification/system/engine/action.php(79): ControllerMailOrder-&gt;index('checkout/order/...', Array)
#4 /home/user/public_html/system/engine/event.php(62): Action-&gt;execute(Object(Registry), Array)
#5 /home/user/storage/modification/system/engine/loader.php(229): Event-&gt;trigger('model/checkout/...', Array)
#6 /home/user/public_html/system/engine/proxy.php(47): Loader-&gt;{closure}(Array, Array)
#7 /home/user/public_html/catalog/controller/extension/payment/cod.php(13): Proxy-&gt;__call('addOrderHistory', Array)
#8 /home/istuserknon/storage/modification/system/engine/action.php(79): Contr in <b>/home/istiknon/public_html/system/library/mail/smtp.php</b> on line <b>91</b><br />
This is what I found in line 91:

Code: Select all

throw new \Exception('Error: ' . $errstr . ' (' . $errno . ')');

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by ADD Creative » Tue Aug 26, 2025 3:37 pm

An error on line 91 could suggest an issue with connecting to the hostname and port. What settings are you using?

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by psytanium » Thu Aug 28, 2025 9:11 pm

ADD Creative wrote:
Tue Aug 26, 2025 3:37 pm
An error on line 91 could suggest an issue with connecting to the hostname and port. What settings are you using?
Mail Engine : SMTP
Mail Parameters: empty
SMTP Hostname: ssl://smtp.office365.com also tried tls://smtp.office365.com
SMTP Username: contact@domainname.com
SMTP Password: ***
SMTP Port: 465 / also tried 587
SMTP Timeout: 5 also tried long, 60

Active Member

Posts

Joined
Fri Nov 27, 2015 2:07 am

Post by ADD Creative » Thu Aug 28, 2025 11:02 pm

Try reentering the settings in case there is some error you can't see such as special character. Use ssl:// with port 465 or tls:// with port 587.

Find and look in you PHP error log as well as the OpenCart one.

If you still get "Uncaught Exception: Error: (0) in /home/user/public_html/system/library/mail/smtp.php:91", try asking your host.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 19 guests