Google mail sending issue in Moodle

Google mail sending issue in Moodle

by Nirosha Rathnayake -
Number of replies: 6

I have setup Moodle to send emails using Google corporate mail account, which sends Moodle notifications/ emails and reset password using Forgot password option.

It worked without any issue upto Moodle 3.7 and now it is not working correctly with latest release. It sends all the internal notifications to relevant students. But only the Forgotten password option is not working. Also the test email does not send in 'Administration > Server > Email and Outgoing email configuration'. It shows following error, enter image description here

I also checked changing to port 465 and SSL, still not working. What could be the issue? Did I missed anything? 

Mail settings;

Site Administration > Server > Email and Outgoing email configuration. And enter following information.
  • SMTP hosts: smtp.gmail.com:587
  • SMTP security: TLS
  • SMTP Auth Type: LOGIN
  • SMTP username: your email address (Eg: noreply@xxxx.xxx)
  • SMTP password: gmail password. Save changes

Average of ratings: -
In reply to Nirosha Rathnayake

Re: Google mail sending issue in Moodle

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
I touch Google as rarely as possible, so little experience. But I suspect the SMTP username should be the envelope sender, the mail address your institution got from Gmail, somename@gmail.com or somename@example.com (example.com is for your mail domain) and not the From: address (noreply@example.com). The easiest way to check the credentials is to configure Thunderbird to use those credentials.

Independently of all that, if your institution has the capacity, own mail servers is the only serious serious solution. Not only because of the dependence from Google, it is a surveillance machine of unheard of dimensions.
Average of ratings: Useful (1)
In reply to Nirosha Rathnayake

Re: Google mail sending issue in Moodle

by Nurbek Tentiev -

Check if the following lines in config.php are commented out.

// When working with production data on test servers, no emails or other messages

// should ever be send to real users

// $CFG->noemailever = true;    // NOT FOR PRODUCTION SERVERS!

//

// Divert all outgoing emails to this address to test and debug emailing features

// $CFG->divertallemailsto = 'root@localhost.local'; // NOT FOR PRODUCTION SERVERS!


Average of ratings: Useful (1)
In reply to Nurbek Tentiev

Re: Google mail sending issue in Moodle

by Nirosha Rathnayake -
Dear All,

Went through your suggestions. They were very helpful to track down the issue.

Actually the issue was with the SELINUX permissions of the server. The issue is sorted now. Thank you very much for your kind support.

Best regards,
In reply to Nirosha Rathnayake

Re: Google mail sending issue in Moodle

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

Was it just the SELINUX setting - no change in SMTP parameters necessary? Specifically SMTP username: noreply@EXAMPLE.COM?
In reply to Visvanath Ratnaweera

Re: Google mail sending issue in Moodle

by Nirosha Rathnayake -
Dear Vishvanath,

Yes. All the SMTP parameters were correct. It was an issue with the SELINUX permissions sad.
setsebool -P httpd_can_sendmail 1 did the trick.

Best regards,
Average of ratings: Useful (2)