Moodle Stopped Sending Emails

Moodle Stopped Sending Emails

by Daniel García -
Number of replies: 5

Hello everyone, I've noticed that our moodle installation stopped sending emails.

We are using a smtp server from our dedicated web hosting. It was working fine until the certificate expired back in september.

I renewed the certificate, I even removed the email account and domain and recreated them again.

If I use no TLS or SSL and use port 25 emails are been sent correctly but as soon as I use TLS and port 587 I get the folliwing error:

2021-10-12 11:30:17	Connection: opening to academytotemguard.com:587, timeout=300, options=array()
2021-10-12 11:30:17	Connection: opened
2021-10-12 11:30:17	SERVER -> CLIENT: 220 *****.******.eu ESMTP Postfix (Ubuntu)
2021-10-12 11:30:17	CLIENT -> SERVER: EHLO plataforma.totemguard.com
2021-10-12 11:30:17	SERVER -> CLIENT: 250-*****.ip-******.eu
                   	                  250-PIPELINING
                   	                  250-SIZE 10240000
                   	                  250-ETRN
                   	                  250-STARTTLS
                   	                  250-ENHANCEDSTATUSCODES
                   	                  250-8BITMIME
                   	                  250-DSN
                   	                  250-SMTPUTF8
                   	                  250 CHUNKING
2021-10-12 11:30:17	CLIENT -> SERVER: STARTTLS
2021-10-12 11:30:17	SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2021-10-12 11:30:17	Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
                   	                  error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [/var/www/vhosts/******/plataforma/lib/phpmailer/src/SMTP.php line 403]
2021-10-12 11:30:17	SMTP Error: Could not connect to SMTP host.
2021-10-12 11:30:17	CLIENT -> SERVER: QUIT
2021-10-12 11:30:17	SERVER -> CLIENT: MIAx&/9΅L3Ax0-9(Vto0O@@gR[Tb݇Vv(VٷhːN)̗,HxzB;IOPLz;~&orRi3k
                   	                  |8iVl*;HHDhZWHdt2yKhH!nGP@YQ9wYa $$ӽ.Ȅ:LLFM|3#
2021-10-12 11:30:17	SMTP ERROR: QUIT command failed: MIAx&/9΅L3Ax0-9(Vto0O@@gR[Tb݇Vv(VٷhːN)̗,HxzB;IOPLz;~&orRi3k
                   	                  |8iVl*;HHDhZWHdt2yKhH!nGP@YQ9wYa $$ӽ.Ȅ:LLFM|3#
2021-10-12 11:30:17	Connection: closed
2021-10-12 11:30:17	SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

At this point I don't know what is failing because I've tested other email apps such us the webmail from our webhosting and the email app from Windows 10 with the same settings as moodle and it works no problem in both places.

Please let me know if you need any further assistance

I'd appriciate any help you can provide

Thanks in advance smile


Average of ratings: -
In reply to Daniel García

Re: Moodle Stopped Sending Emails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Did you talk to the SMTP provider? People suggest remedies like "in VHM under Home »Server Configuration »Tweak Settings »Mail. Then the option Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) was set to Off." https://github.com/PHPMailer/PHPMailer/issues/2061
In reply to Visvanath Ratnaweera

Re: Moodle Stopped Sending Emails

by Daniel García -
Thanks for your answer sir smile
Unfortunetly we own a web hosting but we do not have any support we are the ones who have to check, configure and if there's any issue we are "all alone"
I've checked the settings from the mail server but I don't see any of those there.

Most strange thing is that moodle seems the only application that does not connect to our smtp server
In reply to Daniel García

Re: Moodle Stopped Sending Emails

by Ken Task -
Picture of Particularly helpful Moodlers

ESMTP Postfix (Ubuntu)
so your OS is Ubuntu and you've Postfix.
Postfix configured how?  As local only (will send by not receive)

If above is true, then Postfix should be keeping logs.
What, if anything, do those logs show?

When you say you reinstalled certs those were certs from a commercial CA you purchased
or was that LetsEncrypt?

Ready to start TLS
2021-10-12 11:30:17    Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [/var/www/vhosts/******/plataforma/lib/phpmailer/src/SMTP.php line 403


From command line as root:
openssl s_client -showcerts -connect yoursmtpserverfqdn:587


Investigate your OS's Root CA certificates and look at sslconfig file.

Would you be adverse to using another SMTP relay?

SendGrid offers an API setup that you can set up in moodle.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Daniel García

Re: Moodle Stopped Sending Emails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Aha, I see! You run a VPS under Plesk. Debugging that on moodle.org could have been justified if at least you are on Unix shell.
wink

Anyway, if you want to try, post the two Moodle SMTP configurations, the one without TLS (which works) and the one with TLS (which doesn't). Screen-shots are the best. If there is confidential information screen them, still leaving the pattern visible.

And how do you configure Postfix, the interface to Postfix, I mean?
In reply to Daniel García

Re: Moodle Stopped Sending Emails

by Daniel García -
Thank you for all your help. We ended up switching to a gmail account and we don't see this issue anymore