Forum

Thread tagged as: Problem, Error, Hosting

Email suddenly not working

Hi!

Our new site has been live for a few months now and we have been using Office 365 as our SMTP in Perch. The email test worked just find and form was sending emails like it should, but suddenly it stopped working a few weeks ago. I have been investigating the problem with Microsoft and our webhotel's host, but they did not find anything indicating a problem on their end. I've posted my email settings in config.php below.

define('PERCH_EMAIL_FROM', 'example@something.com');
define('PERCH_EMAIL_FROM_NAME', 'Yhteydenotot nettisivuilta');
define('PERCH_EMAIL_METHOD', 'smtp');
define('PERCH_EMAIL_HOST', 'smtp.office365.com');
define('PERCH_EMAIL_AUTH', true);
define('PERCH_EMAIL_SECURE', 'tls');
define('PERCH_EMAIL_PORT', 587);
define('PERCH_EMAIL_USERNAME', 'example@something.com');
define('PERCH_EMAIL_PASSWORD', '##########');

(I have censored password and used a dummy email account in the code above. The account is a licensed, working O365 Business account and the password is 100% correct on my real setup)

Could it be possible, that something is changed or wrong with Perch? I haven't done any changes myself but still the email stopped working some time ago. Only thing I did was some email template modifications during the same time window but it still worked a few times after that. Then it stopped working altogether. Might be a coincidence, as I reverted the template back to the previously working version and it didn't help.

To sum it up, when I try to do the email test, it loads a few minutes and then gives me a "504 Gateway Time-out - openresty" error, and if I try to refresh/login during that time, it just continues loading and finally forwards me back to Perch login page. That still seems like a problem with the webhotel's host server? Still they couldn't find anything indicating to be the root cause for this.

I appreciate any insight and help regarding this problem!

Kind regards, Tomi

Tomi Tähti

Tomi Tähti 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It does sound like a hosting issue of some sort. Have you tried switching to a different SMTP server to narrow it down?

You could try Mailtrap. https://mailtrap.io

Hi Drew!

Actually it seems mailtrap works so it must be on Microsoft's end somehow. I have not used mailtrap before, it seems to be a great tool for testing.

I will continue investigating the issue with Microsoft again. Thanks!

Kind regards, Tomi

Hey!

I've continued investigating this problem and it is still not solved. I have been discussing the problem with both our host's (Hostinger) and Microsoft's support teams about the problem. Both are now saying there's nothing wrong at their end. Microsoft's support staff asked me if I could show the SMTP logs. I tried to find these SMTP logs but can't find them anywhere. Does Perch have any feature/logs where I could see the SMTP errors or other SMTP activity/events/info?

Thanks!

Kind regards, Tomi

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, Perch doesn't have an SMTP log.

Hi Drew and thank you for the information!

I noticed that I'm getting these entries in my server's PHP error log when trying to send test email with Office 365 SMTP configuration:

[04-Jul-2018 09:50:51 Europe/Helsinki] PHP Warning:  PDO::query(): MySQL server has gone away in /home/XXXXXXX/public_html/perch/core/lib/PerchDB_MySQL.class.php on line 170
[04-Jul-2018 09:50:51 Europe/Helsinki] PHP Warning:  PDO::query(): Error reading result set's header in /home/XXXXXXX/public_html/perch/core/lib/PerchDB_MySQL.class.php on line 170
[04-Jul-2018 09:50:51 Europe/Helsinki] PHP Fatal error:  Uncaught Error: Call to a member function find_app_title() on boolean in /home/XXXXXXX/public_html/perch/core/templates/layout/sidebar.php:40
Stack trace:
#0 /home/XXXXXXX/public_html/perch/core/templates/layout/top.php(78): include()
#1 /home/XXXXXXX/public_html/perch/core/inc/top.php(20): include('/home/XXXXXXX...')
#2 /home/XXXXXXX/public_html/perch/core/settings/email/index.php(18): include('/home/XXXXXXX...')
#3 {main}
  thrown in /home/XXXXXXX/public_html/perch/core/templates/layout/sidebar.php on line 40

(User part of the paths omitted) Could this be related to the problem in any way or is it just a coincidence to get those lines in the error log the same time when trying to send the test email? If it's not related, it would be nice to know what is causing those errors? :)

Thanks!

Kind regards, Tomi

Drew McLellan

Drew McLellan 2638 points
Perch Support

What sort of hosting is this? That error looks like a database connection failure, which you should really never get.

Hi Drew!

It's the Business level (best of three subscription models) web hotel/shared hosting plan from Hostinger.

Kind regards, Tomi

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd hope that should be ok, but it might be worth asking Hostinger about that error message.

Hi Drew!

I asked Hostinger about these errors and this is how they replied:

If you see the error message 'MySQL Server has gone away', it is possible that your script is not fully optimized and makes too many connections to the database. It may also happen due to excessive amounts of traffic. Another probable cause for this issue may be heavy or slow MySQL queries.

In either case, in order to solve this problem, you should check if your database is well optimized and has indexes set up correctly. If you are using a 3rd party script, you should definitely try contacting script developers and ask them for assistance on this matter!

Kind regards, Tomi

i had somewhat similar issue My Email host company says they are using following encryption Encryption: SSL\TLS , but when I add ssl://mail.shadowmail.com.au I get "Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol" error from my Email library on Filename: libraries/Email.php Line Number: 2055 – learner Jan 18 at 0:18 does it mean something wrong with my ssl certificate – learner Jan 18 at 0:20 I got this response form server when trying to send email The following SMTP error was encountered: 0 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. – learner Jan 18 at 0:21 You should double check with them about exactly how they have it implemented, because neither STARTTLS nor a pure TLS negotiation works for the server you've specified. – Sammitch Jan 18 at 1:19 I am trying with gmail and getting same problem , $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => '******@gmail.com', 'smtp_pass' => '******', 'mailtype' => 'html', 'charset' => 'iso-8859-1' ); $this->load->library('email', $config); $this->email-

Hi Drew,

Do you have an Office 365 email account available? If you have, is there any chance you could test if it works on your instance/server? That would be a definitive way to know if the problem really is on our server (Hostinger) or not. :)

Kind regards, Tomi

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't have one of those, no. You've proved that SMTP is working by testing with Mailtrap, haven't you?

Hi Drew,

Yes SMTP itself is working, it just would have been great to have someone else test this (Perch SMTP with O365 config) on a different server. That way I could go to my host and tell them it really seems to be a problem with our web server. But anyways, thanks for the replies!

Kind regards, Tomi