General help

email to hotmail and gmail not working

 
tom
email to hotmail and gmail not working
 

Hey Guys,


we're having trouble getting the mail settings right.

I'm working with moodle 3.3+ (Build: 20170519) on  a small server and most of it is working fine except the email.

I can send emails to some domains, but not to hotmail.com or gmail.com (maybe more).


I used the following smtp setup:

server: mail.mijdomein.nl:465


The solution is maybe to setup an spf-record at my email dns (external company), but I have suitecrm installed on the same server with the same configuration and it can send mails to all domains. The external company demands that i specify the spf-record, but I have no clue what to send them


Anyone know what to do?


Tom

P.S. I'm dutch so sorry if my English is not correct.

 
Average of ratings: -
Picture of Howard Miller
Re: email to hotmail and gmail not working
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Ask whoever administers the mail exchanger  for mail.mijdomein.nl to check the logs for your traffic to gmail and hotmail. 

I would expect that your mail is being rejected for some security related reason. This is really quite common. 

Configuring a mail exchanger and administering it is non-trivial and requires quite a lot of specific knowledge. I would try to avoid it. These days, things like SPF records are, effectively, mandatory if you want to deliver mail reliably. However, none of this is really a Moodle issue.

 
Average of ratings: -
Picture of Ken Task
Re: email to hotmail and gmail not working
Particularly helpful Moodlers

For general/overall info on SPF, please see:

https://www.google.com/search?q=spf+record+DNS&ie=utf-8&oe=utf-8

for a tool to help generate an SPF text record for DNS, please see:

https://www.spfwizard.net/

Howard is correct ... it really isn't a Moodle issue ... change nothing to your config for SMTP in Moodle.  Once mail leaves the moodle the fate of the messages themselves are at the mercy of DNS and other mail systems and what checks those mail systems use to accept/reject mail.

Trouble shooting ... ie, figuring out why messages are rejected ... involves some outside testing or one gets an incomplete picture and starts chasin' rabbits down wrong rabbit holes, so ...

Is the mail server linux?   Do you have ssh access to that mail server?   If so, one could login to it, install alpine (text based MTA).   Then one could test directly from that mail server ... that's the one gmail and hotmail will see initially.   Send a test message to a gmail or hotmail address and the rejection will have a notice sent back to the mail server (called a bounce).    Reading the rejection notification will give you some info. and hopefully, suggestions as to how you can resolve the issue at the SMTP mail server.

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Jorge Fernández
Re: email to hotmail and gmail not working
 

Hi Ken

Sorry for my lack in English

I have a site with Moodle 3.4+ and a weeks ago i have an issue with the confirmation emails when a user create an account. verification email it never has sent, Moodle refuse to send it. Or when you forgot your password, the reset password email has not sent by Moodle

I have created a php file and save it, to check and send a simple email. The file is like this:

<?php
 $to = "recipient@example.com";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 if (mail($to, $subject, $body)) {
 echo("<p>Email successfully sent!</p>");
 } else {
 echo("<p>Email delivery failed…</p>");
 }
 ?>

and run it (php file) and all are ok, emails to diferent domains are sent, not only hotmail and gmail.

But Moodle installed in the same domain (folder) doesn't send it

I installed plugin email test and it reports that all are ok, it said email was sent and all are ok, but email didn't arrive 

If an account is from another domaind not hotmail or gmail, verification emails is sent

I've read a lot of forums and don't have a clue what is going on

Please help me. Thanks in advance

Sorry for my lack in English

 
Average of ratings: -
Picture of Ken Task
Re: email to hotmail and gmail not working
Particularly helpful Moodlers

@Jorge ... your English is just fine! ;)

Is your site running cron often enough?

There is a task which is called by cron job running for many things Moodle.

If you have Linux, you can run the cron job via command line.

cd /path/to/moodle/code/admin/cli/

php cron.php

In the output look for references to mail related jobs/task.

When you create your own php script, that script will use whatever mail transfer agent is installed on the system - which could be sendmail or postfix (an MTA).  

If you access in Moodle, the php info link, you might see/should see what php is using in the 'Core' section ... and rows for sendmail_from and sendmail_path

For testing purposes, one could install Postfix or use sendmail which is probably already on your system if you are not on a shared system.   Don't configure it to receive mail ... by default it installs for localhost mail only.  Leave it that way.

Could also install a mailer ... Alpine comes to mind.

With Alpine one could address a test message to whatever address isn't getting notifications ... this does NOT use Moodle's PHPMailer but your postfix or sendmail.   Advantage in doing this ... if port 25 isn't blocked ... outbound ... the test message will leave your server and attempt delivery of the message.   If i fails, you will be able to see the reason why in the mail server logs.  In those notices the mail system to which the message was addressed normally provides a URL that you could go check out to find what that mail server found objectionable about the message you sent.

More than likely the other mail server did checks on mail coming from your server and determined it was 'spam'.   Mail servers or Mail gateways do a lot of checking for characteristics of the entire message.   Most Moodles do NOT have mx records in dns, nor spf, dkim records which are checked by mail servers/gateways getting mail from your Moodle.

More often that not, the setup of an SMTP relay solves the issues.  SMTP serves do have all those DNS records, etc.

'spirit of sharing', Ken

 
Average of ratings: Useful (1)
Picture of Jorge Fernández
Re: email to hotmail and gmail not working
 

Hi Ken


Thanks to answer me


Moodle site is in shared host, son i can't install a mailer

The cron job is executed often and output doesn't have a text job/task related to mail


The confirmation email o password reset are not sent because they have a link and a few paragraphs of text


If a put the code i've created in a php file, like the above example, it did send a short email to gmail or hotmail; but when a email has a lot of text and a link, it doesn't arrive to inbox/spam in hotmail or gmail.


So, i think short emails or if it doesn't have a link, hotmail or gmail don't detect and it can arrive


Can I modify the php file from Moodle to cut some text or change the link confirmation, so gmail or hotmail don't refuse the arrive?

Which is this file i must change?

Is there another solution to this problem?

big grin

Thanks in advance!!!

 
Average of ratings: -
tom
Re: email to hotmail and gmail not working
 

Hey Guys,


Thanks for the info. I'm working on it with my email provider at the moment.


Greetings,


Tom

 
Average of ratings: -
LionHeart stretching
Re: email to hotmail and gmail not working
 

Hey hey, a two month necro. Not bad for me!

Tom, if you're dealing with a Gmail account that's for an education institution, there's a default restriction for those domain to only accept e-mails from other Gmail authenticated/backed/validate domains.  (I don't have access to the backend of such a system, so I do not know the exact technical language used to identify the term.)

I ran into this literally just now with a customer and came across your post while trying to figure out if anything can be done to make the receiving end OK with such e-mails. (Which if the case, could be a security issue so am happy I have not stumbled across such a workaround - yet.)

My understanding is there's a whitelist that can be used to allow e-mails from 'outside' domains to be received, but again without access to the receivers end, I don't know specific terms to be able to narrow down to a specific area.

 
Average of ratings: -