Moodle messages are detected as spam in external mail servers

Moodle messages are detected as spam in external mail servers

by Manuel Peño del Barrio -
Number of replies: 5

Hello everyone!

In our institution is not possible to assign a mailbox on the mail server of our domain to each user that is created into the platform. Therefore, we manually create each user account with email transmitted to us.

We are having problems with our Moodle messaging system. We use mainly forums suscription and internal messaging (e.g. Send message button from user view). We made two tests in shaping the mailing:

  • To relay, we used Microsoft Exchange as the SMTP server to which it connects Moodle.

In this case, when a user (e.g. a tutor) attempts to send a message to another user (e.g a student), we get the following error: SMTP Error: Data not accepted.

Debugging and tracing, we found that the particular error is: 550 5.7.1 Client does not have permissions to send as this sender, and that Moodle is sending this to Exchange:

PHPMailer::__set_state(array(
[…]
'From' => 'xxxxx@externaldomain1.com',
'FromName' => 'Test User 1',
'Sender' => 'moodleadm@mydomain.com',
'Host' => 'mail.mydomain.com',
'Port' => 25,
'SMTPAuth' => true,
'Username' => 'moodleadm',
'Password' => 'ZZZZZZZ',
'to' => array ( 0 => array ( 0 => 'yyyyy@externaldomain2.com', 1 => ' Test User 2', ), ),
[…]
));

  • Using the PHP default method (which is based on sendmail, because our installation is Linux).

In this case, emails are sent to the Internet directly, arriving at an external email account (gmail, hotmail ...). But have told us that we are entering in the blacklisting of some external mail servers.

Regarding the first scenario, document http://docs.moodle.org/20/en/Email_setup_gmail indicates that if you want to use Gmail as a relay, would not be possible to keep the header 'From' emails that users have in Moodle. Instead, they would be replaced by the email that Moodle uses to connect to Gmail.

In the second case, our consultant told us that the reason we are being included in their blacklist may be because they think we are doing phishing because we specified in the 'From' header a mail with different domain than the mail in header 'Sender'.

My question is this: is it necessary that all users of Moodle have their accounts in the same mail server and it is in the 'Mail Exchange' list of the Moodle domain (MX record in DNS)? Is there a way that each user can have their own preferred external email and Moodle can send messages that allow to Moodle receivers, from their own email service, know the email of the Moodle user who is sending it?

To avoid being seen as a spammer for these reasons, we toyed with the option to edit the source code so that 'Sender' and 'From' headers always contain moodleadm@mydomain.com and always include at the beginning of the body a line such as "Mail sent from Moodle (http://www.mydomain.com/moodle) on behalf of xxxxx@externaldomain1.com".

Any suggestions, comments or help is welcome.

Thanks a lot!

Average of ratings: -
In reply to Manuel Peño del Barrio

Re: Moodle messages are detected as spam in external mail servers

by Andrew Bones -
Hello Manuel, We had a same problem, For us is acceptable the next decision: We use an external mail server (our Internet provider) for send all of moodle emails. Moodle->Administration->Server->Email SMTP host: mail server of Internet provider User: Pass: The advice for the programmer: Into the code use Moodle function "email_to_user" not PHP function "mail". Regard,
In reply to Andrew Bones

Re: Moodle messages are detected as spam in external mail servers

by Mari Cruz García -

Can you please advice about how to change the code?

I don't quite understand what I need to change.

In reply to Andrew Bones

Re: Moodle messages are detected as spam in external mail servers

by Graham Stone -
Picture of Testers

Hello,

I know that this is an old thread but we are having the same problem.  Please can somebody advise where this code needs changing?

Thanks,

In reply to Graham Stone

Re: Moodle messages are detected as spam in external mail servers

by Graham Stone -
Picture of Testers

Just bumping this up since nobody has replied for almost 2 weeks.  Please can somebody advise if this is still an issue if if so where do I need to change the code?

Thanks,