Hard to debug Email Messaging Problem

Hard to debug Email Messaging Problem

by Breno Jacinto -
Number of replies: 4

Dear friends,


     It's been a couple of days of searching and experimenting different solutions to our peculiar problem of sending emails. Our server has been migrated at DigitalOcean, and since then emails have stopped working. I have tried two approaches:


1) Using a local server - but our messages continually go to SPAM and we'd need to set SPF parameters, etc. 

2) Using Gmail's SMTP. That would be an easier solution and it had worked before, but now it's quite a pain. 


     Let me give you guys our configuration in the image attached. Our Moodle version is 2.8.2. 

      Our scenario is simple: no emails are being delivered. We send messages, but emails dont reach their respective destinations. I've been testing it using one-to-one messaging to debug. I have added the debug configurations at our config.php: 

$CFG->divertallemailsto = 'brenojac@gmail.com';

$CFG->debugsmtp = 1;


      And here's what we get in apache's error.log while trying to send a message: 

sendmail: fatal: www-data(33): No recipient addresses found in message header

sendmail: fatal: www-data(33): No recipient addresses found in message header

sendmail: fatal: www-data(33): No recipient addresses found in message header

sendmail: fatal: www-data(33): No recipient addresses found in message header


       Now, what could be the possible reason Moodle is not being able to get the recipient's address? That question I'd like your help to be answered. 


       Another simple test: We are able to reach Gmail's SMTP server at 465:


root@guinteract:/var/www/moodle# telnet smtp.gmail.com 465

Trying 74.125.29.108...

Connected to gmail-smtp-msa.l.google.com.

Escape character is '^]'.



best regards,


- Breno





Attachment MoodleEmailSetup.png
Average of ratings: -
In reply to Breno Jacinto

Re: Hard to debug Email Messaging Problem

by Ken Task -
Picture of Particularly helpful Moodlers

What, exactly, does this mean? "Our server has been migrated at DigitalOcean" ... moved to a different IP address?

If it worked before, but not now, wonder if the former user of that IP managed to get their site listed in SBL or other blackhole.    BTW, the telnet test shows you reached a port but didn't show the other commands one uses to actually login to the gmail.com account.

In your screen shot, I see the google stmp server with a space then a port.   Isn't it common to use server:port on most things?

However, see these:

https://docs.moodle.org/22/en/Email_setup_gmail

https://moodle.org/mod/forum/discuss.php?d=51833

and this one:

https://moodle.org/mod/forum/discuss.php?d=337258#p1359450

last was a hack of code to get it to work and for a version 1.9.x (Not recommended) ... but we do what we must!

'spirit of sharing', Ken

In reply to Ken Task

Re: Hard to debug Email Messaging Problem

by Breno Jacinto -

Hello Ken,


    Thanks for you reply. I meant that they should have upgraded our machine, while keeping our IP addresses. I dont think being tagged as spammers would be the problem - our messages arent even leaving the server and the only error I get is is that: " No recipient addresses found in message header", which seems to be the way Moodle is building the messages prior to sending them to Gmail's SMTP server. 


    There's a : between the smtp address and port. The suggestions links were helpful, but I'd rather perform an upgrade to the latest version. Maybe that will fix the problem. I'm running out of options. 


best regards,


- Breno

In reply to Breno Jacinto

Re: Hard to debug Email Messaging Problem

by Ken Task -
Picture of Particularly helpful Moodlers

So DO migrated server ... ie, upgraded ... same IP ... upgraded from what to what?   Example: CentOS 5 to CentOS 7?  While providers say they can do that in place ... see conflicting and/or catch 22's in the distro's forums.

Did you have sendmail setup with a smarthost before? OR some other MTA?

Config of Moodle using Google previously now broken.  With Google stuff, there is usually/normally setup required on the Google end as well.   That shouldn't have changed. DO does note of that.   But did you check it?  (the account being used).

DO's info: https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server

Moodles debug for Mail https://docs.moodle.org/31/en/Debugging#Debug_email_sending

The latter might provide some more info than what you are seeing.

For other ways of testing ... IF Linux ... install alpine from repos.  That's a text based MTA/mailer - NOT PHP - it can be configured to use Google as SMTP with credentials and change things like reply to headers, etc..  And one can check their own mail logs and see responses/rejections/other from Google as well.

'spirit of sharing', Ken


In reply to Ken Task

Re: Hard to debug Email Messaging Problem

by Breno Jacinto -

Hi Ken,


   As I suspected, upgrading to 3.1 solved my problem. By the way, the debugging got A LOT easier by dumping the whole SMTP protocol messages after sending any message in debug mode. Moodle rocks smile.


     As for why I was getting those errors in the previous version - I really dont know. Some misteries are to be left unsolved smile.  


     Thank you very much for your attention and help.


- Breno