michael-milette / moodle-local_mailtest

Moodle MailTest allows administrators to test Moodle's email system. A trace of the SMTP dialogue will be displayed if the email message cannot be sent for any reason. For premium support, contact us at https://www.tngconsulting.ca/contact
https://moodle.org/plugins/local_mailtest
GNU General Public License v3.0
19 stars 12 forks source link

From address left empty on test email #7

Closed kg4ysy closed 7 years ago

kg4ysy commented 7 years ago

I am trying to send a test email, but the "From" is left empty. This causes the email to fail. I have chosen our no-reply email for the "From" from the first step, but it isn't being used. Is this a bug with the plugin or something in Moodle?

2017-02-15 13:35:16 SERVER -> CLIENT: 354 Start mail input; end with . 2017-02-15 13:35:16 CLIENT -> SERVER: Date: Wed, 15 Feb 2017 08:35:12 -0500 2017-02-15 13:35:16 CLIENT -> SERVER: To: myemail@emaildomain.com 2017-02-15 13:35:16 CLIENT -> SERVER: From: "" 2017-02-15 13:35:16 CLIENT -> SERVER: Subject: Test Email

michael-milette commented 7 years ago

Hi kg4ysy,

Thank you for your question. Though certainly not impossible, I am quite confident that it is very unlikely that the problem is with the plugin. All the plugin does is to use Moodle's standard functions to try to send the email and display the resulting dialogue between Moodle and the mail server including any error message. It doesn't actually create the log itself. Although you didn't mention it, if you are getting an error with the plugin, I suspect that your Moodle site might also be experiencing the same issue.

Techy note: If you have configured the SMTP server settings in Moodle, it actually uses a very popular open source PHP class library called PHP Mailer to communicate with SMTP servers. It is what actually generates the log. You can learn more about this library by visiting http://phpmailer.worxware.com/

Without seeing the rest of the log and your configuration settings in Moodle, I can only speculate as to the cause of your issue. However I recently experienced the same symptoms you are describing on a brand new Moodle 3.2 installation. What confused me for a while is that a Moodle 3.1 installation on the same server, which seemed to be configured the same way, worked perfectly. Eventually I found the reason - Moodle 3.2 changes the way it implements the no-reply address field. It also adds some extra validation to ensure that the email address meets RFC standards. So for example, if you have a site running locally, noreply@localhost would be rejected even if you have a mail server running on localhost because there is no TLD (top level domain - example .com - at the end of the address.

This lead me to release the most recent release version 1.1 of the plugin a couple of weeks ago which displays additional error information generated by Moodle but not normally seen.

In my case, it turned out to be a configuration issue between Moodle and the mail server. The problem was that I was using an email address which didn't actually exist (example: noreply@emaildomain.com). The email server was rejecting this. As soon as I replaced the no-reply email address with a real and valid email address in the Moodle configuration page, the server had no problem processing the message and the email address appeared correctly in the log.

My suggestion would be to temporarily try setting a real and valid email address to the no-reply field in Moodle. If this works for you, you'll have your answer. If you are not sure where this is, just click on the "change" link for the no-reply address From field in the plugin.

An alternative solution might be to configure your email server to allow non-existing email addresses in the From field, like no-reply@emaildomain.com but I haven't tried this myself.

Another reasons this might happen is if you have something in the "Allowed email domains" of the No-reply section of the Outgoing email configuration page in Moodle 3.2. Make sure this field is completely empty - not even a black space. This Moodle configuration page can also be accessed by clicking on the "Change" link next to the no-reply field in the eMailtest page.

Hope something in here helps and please let me know how it turns out.

If nothing helps, I suggest you 1) make sure you are using the most recent version of eMailtest on https://moodle.org/plugins/local_mailtest and 2) look for other error messages on the page. In order to help you further, you will need to provide additional information.

I also offer paid Moodle support where I troubleshoot your system and resolve the issue for you. If this is of interest to you, please contact me through my website at www.tngconsulting.ca/contact-us/

Best regards,

Michael Milette

kg4ysy commented 7 years ago

It looks like it was a bug in Moodle. Thanks for the excellent feedback. Updating Moodle to 3.2 fixed the issue.