General help

SMTP problem with Moodle 3.0 (Build: 20151116)

 
Picture of Franco Bo
SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi guys,

I've checked the FORUM and all the other resources but even after trying all the solutions I could find [eg. https://docs.moodle.org/30/en/Messaging_settings etc.] my specific problem is unsolved.


---PROBLEM:

I've updated Moodle to the 3.0 version and just now I discovered that it cannot send email anymore. Before I had no problem with SMTP and sending emails. I'm not sure the updeate was the reasons for this problem, but I believe it is an info worth sharing.


---WHAT I'VE TRIED SO FAR:

I've checked with my service provider the info for the SMTP settings, and they confirm that are correct:

smtphosts: mail.mywebsite.com or srv.hdedi-xl400.org

smtpsecure: NONE
SMTP Auth Type: LOGIN
SMTP username: moodle@mywebsite.com
Character set: UTF-8
Newline characters in mail: LF

I've also created a SMTP account in Thuderbird and I have verified that in this way (and with the same settings) I've no problem in sending the emails. So I think it is reasonable to believe the problem is not in the setting info.

In Moodle I've also tried with the port 465 for SSL, and port 587 for TLS, but still cannot send any email.

I've also enabled the Debugging mode for SMTP (below is the LOG I get).

I do not know what to do anymore, anyone has any idea of what I am doing wrong or what the problem could be?  Thanks in any case... smile





---SMTP Error Log

2015-12-12 19:10:25    Connection: opening to mail.mysite.com:25, timeout=300, options=array (
                                         )
2015-12-12 19:10:25    Connection: opened
2015-12-12 19:10:25    SMTP -> get_lines(): $data is ""
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "220-srv.hdedi-xl400.org ESMTP Exim 4.86 #2 Sat, 12 Dec 2015 20:10:25 +0100
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "220-srv.hdedi-xl400.org ESMTP Exim 4.86 #2 Sat, 12 Dec 2015 20:10:25 +0100
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "220-We do not authorize the use of this system to transport unsolicited,
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "220-srv.hdedi-xl400.org ESMTP Exim 4.86 #2 Sat, 12 Dec 2015 20:10:25 +0100
                                         220-We do not authorize the use of this system to transport unsolicited,
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "220 and/or bulk e-mail.
                                         "
2015-12-12 19:10:25    SERVER -> CLIENT: 220-srv.hdedi-xl400.org ESMTP Exim 4.86 #2 Sat, 12 Dec 2015 20:10:25 +0100
                                         220-We do not authorize the use of this system to transport unsolicited,
                                         220 and/or bulk e-mail.
2015-12-12 19:10:25    CLIENT -> SERVER: EHLO mysite.com
2015-12-12 19:10:25    SMTP -> get_lines(): $data is ""
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250-SIZE 52428800
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250-8BITMIME
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         250-8BITMIME
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250-PIPELINING
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         250-8BITMIME
                                         250-PIPELINING
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250-AUTH PLAIN LOGIN
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         250-8BITMIME
                                         250-PIPELINING
                                         250-AUTH PLAIN LOGIN
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250-STARTTLS
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $data is "250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         250-8BITMIME
                                         250-PIPELINING
                                         250-AUTH PLAIN LOGIN
                                         250-STARTTLS
                                         "
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "250 HELP
                                         "
2015-12-12 19:10:25    SERVER -> CLIENT: 250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         250-8BITMIME
                                         250-PIPELINING
                                         250-AUTH PLAIN LOGIN
                                         250-STARTTLS
                                         250 HELP
2015-12-12 19:10:25    CLIENT -> SERVER: STARTTLS
2015-12-12 19:10:25    SMTP -> get_lines(): $data is ""
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "220 TLS go ahead
                                         "
2015-12-12 19:10:25    SERVER -> CLIENT: 220 TLS go ahead
2015-12-12 19:10:25    SMTP Error: Could not connect to SMTP host.
2015-12-12 19:10:25    CLIENT -> SERVER: QUIT
2015-12-12 19:10:25    SMTP -> get_lines(): $data is ""
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

same problem here. I upgraded from 2.9 latest to 3.0 and mail stopped working. You can see in my mail logs when the upgrade happened - suddenly it only connects and disconnects, but no more messages:

Dec 29 16:49:32 in postfix/smtpd[12097]: connect from unknown[192.168.2.3]

Dec 29 16:49:32 in dovecot: auth: Debug: client in: AUTH#0111#011LOGIN#011service=smtp#011nologin#011lip=192.168.2.20#011rip=192.168.2.3

Dec 29 16:49:32 in dovecot: auth-worker: Debug: sql(postmaster@ritacollege.be,192.168.2.3): query: SELECT username as user, password, '/var/vmail/ritac

ollege.be/postmaster' as userdb_home, 'maildir:/var/vmail/ritacollege.be/postmaster' as userdb_mail, 150 as userdb_uid, 8 as userdb_gid FROM mailbox WHERE username = 'blabla@blabla.be' AND active = '1'

Dec 29 16:49:32 in postfix/smtpd[12097]: 19B9372D7DB9: client=unknown[192.168.2.3], sasl_method=LOGIN, sasl_username=blabla@blabla.be

Dec 29 16:49:32 in postfix/smtpd[12097]: disconnect from unknown[192.168.2.3]

Dec 29 16:49:33 in amavis[11482]: (11482-20) Passed CLEAN, LOCAL [192.168.2.3] [192.168.2.3] <koen.roggemans@ritacollege.be> -> <blablas@sblabla.be>, Message-ID: <e784ebbabfbac1077194e0763564b6e6@blabla.be>, mail_id: sjc3UZzYQqCY, Hits: -2.9, size: 1300, queued_as: 5D0C572D7F2 3, 1245 ms

Dec 30 18:00:03 in postfix/smtpd[31753]: connect from unknown[192.168.2.3]

Dec 30 18:00:03 in postfix/smtpd[31753]: Anonymous TLS connection established from unknown[192.168.2.3]: TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)

Dec 30 18:00:03 in postfix/smtpd[31753]: disconnect from unknown[192.168.2.3]

I found MDL-52637 which is marked as a duplicate, but that is the only one about 3.0, while all other mentioned bugs are about 2.x; In my case it is definitely the change to 3.0 - earlier versions worked.

Also weird is that it makes a TLSv1 connections, while secure is turned off on my site.

Similar question on http://stackoverflow.com/questions/34412978/smtp-error-with-sending-emails-on-moodle-3-0

PHPmailer was updated for Moodle 3.0 in MDL-51526

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Koen,

happy to know I'm not alone smile I guess we share the same problem, I'm 85% confident the problem with SMTP/PHPmailer showed after the 3.0 upgrade.

Did you find any solution?


The only tip that I found in the links you shared (thanks) is about installing earlier version of PHPmailer (btw I've to check how to do it). Did this work for you?


Thanks a lot!

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Koen,


after your email I've done another check.


I downgraded Moddle from 3.0 to 2.8.... and now the email are sent without any problem! No PHPmailer or SMTP problem... I guess there is some issue with Moodle 3.0 so I'll stick with 2.8 till in one of the next versions the SMTP problem will be solved!

If anyone has a different way to work with Moodle 3.0 and have a functioning SMTP/PHPmailer, please let me know smile

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

I can't downgrade anymore, so I have to find another solution. I'll keep you posted.

Kind regards

Koen

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

I noticed phpmailer went from version 5.2.9 to 5.2.13, going from Moodle 2.9 to Moodle 3.0.

In the phpmailer changelog I notice in the release notes for 5.2.10 the following sentence: 

  • Automatic opportunistic TLS encryption even if you don't specify SMTPSecure = 'tls'

So apparently it is not possible anymore to connect without using TLS. 

Wild guess: I think we both try to connect without encryption and that doesn't seem to work anymore. If that is the case, then the possible settings seem to be somewhat misleading.

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

So I checked the TLS login on the mailserver, command line, coming from the machine where Moodle runs on, using the same username, password, AUTH LOGIN, using port 587.

Command line I get an authentication succes, Moodle debug gives me an authentication failure. Why?

2016-01-06 15:55:37	Connection: opening to 192.168.2.20:587, timeout=300, options=array (
                   	                  )
2016-01-06 15:55:37	Connection: opened
2016-01-06 15:55:37	SMTP -> get_lines(): $data is ""
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "220 uit.ritacollege.be ESMTP Postfix (Debian/GNU)
                   	                  "
2016-01-06 15:55:37	SERVER -> CLIENT: 220 uit.ritacollege.be ESMTP Postfix (Debian/GNU)
2016-01-06 15:55:37	CLIENT -> SERVER: EHLO elo.ritacollege.be
2016-01-06 15:55:37	SMTP -> get_lines(): $data is ""
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-uit.ritacollege.be
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-PIPELINING
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-SIZE 26214400
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-VRFY
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-ETRN
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-STARTTLS
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-STARTTLS
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-ENHANCEDSTATUSCODES
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-STARTTLS
                   	                  250-ENHANCEDSTATUSCODES
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-8BITMIME
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-STARTTLS
                   	                  250-ENHANCEDSTATUSCODES
                   	                  250-8BITMIME
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250 DSN
                   	                  "
2016-01-06 15:55:37	SERVER -> CLIENT: 250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-STARTTLS
                   	                  250-ENHANCEDSTATUSCODES
                   	                  250-8BITMIME
                   	                  250 DSN
2016-01-06 15:55:37	CLIENT -> SERVER: STARTTLS
2016-01-06 15:55:37	SMTP -> get_lines(): $data is ""
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "220 2.0.0 Ready to start TLS
                   	                  "
2016-01-06 15:55:37	SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2016-01-06 15:55:37	CLIENT -> SERVER: EHLO elo.ritacollege.be
2016-01-06 15:55:37	SMTP -> get_lines(): $data is ""
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-uit.ritacollege.be
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-PIPELINING
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-SIZE 26214400
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-VRFY
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-ETRN
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-ENHANCEDSTATUSCODES
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-ENHANCEDSTATUSCODES
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250-8BITMIME
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $data is "250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-ENHANCEDSTATUSCODES
                   	                  250-8BITMIME
                   	                  "
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "250 DSN
                   	                  "
2016-01-06 15:55:37	SERVER -> CLIENT: 250-uit.ritacollege.be
                   	                  250-PIPELINING
                   	                  250-SIZE 26214400
                   	                  250-VRFY
                   	                  250-ETRN
                   	                  250-ENHANCEDSTATUSCODES
                   	                  250-8BITMIME
                   	                  250 DSN
2016-01-06 15:55:37	SMTP Error: Could not authenticate.
2016-01-06 15:55:37	CLIENT -> SERVER: QUIT
2016-01-06 15:55:37	SMTP -> get_lines(): $data is ""
2016-01-06 15:55:37	SMTP -> get_lines(): $str is  "221 2.0.0 Bye
                   	                  "
2016-01-06 15:55:37	SERVER -> CLIENT: 221 2.0.0 Bye
2016-01-06 15:55:37	Connection: closed
2016-01-06 15:55:37	SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Error calling message processor email
  • line 127 of /lib/classes/message/manager.php: call to debugging()
  • line 88 of /lib/classes/message/manager.php: call to core\message\manager::send_message_to_processors()
  • line 229 of /lib/messagelib.php: call to core\message\manager::send_message()
  • line 2349 of /message/lib.php: call to message_send()
  • line 217 of /message/index.php: call to message_post_message()


 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Koen,
could you try:

diff --git a/lib/phpmailer/moodle_phpmailer.php b/lib/phpmailer/moodle_phpmailer.php
index b502d4a..a835bcc 100644
--- a/lib/phpmailer/moodle_phpmailer.php
+++ b/lib/phpmailer/moodle_phpmailer.php
@@ -52,6 +52,8 @@ class moodle_phpmailer extends PHPMailer {
         global $CFG;
         $this->Version   = 'Moodle '.$CFG->version;         // mailer version
         $this->CharSet   = 'UTF-8';
+        // Disable the automatic TLS encryption added in v5.2.10.
+        $this->SMTPAutoTLS = false;

         if (!empty($CFG->smtpauthtype)) {
             $this->AuthType = $CFG->smtpauthtype;

?

HTH,
Matteo

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

Thanks for you suggestion Matteo. 

Adding your suggested line didn't help, unfortunately: the same authentication problem turned up . I even tried with various accounts on the mail server (eventually you start doubting everything).

I managed to get it working in the following non elegant way:

  • ip-addres mailserver:587
  • TLS
  • LOGIN
  • username empty
  • password empty

On the mailserver (postfix) I added the server IP to mynetworks and added smtpd_sasl_exceptions_networks = $mynetworks to main.cf


 

 
Average of ratings: Useful (3)
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Koen,
it was a quick idea: what were your settings before changing them as above?

I'm looking at https://github.com/moodle/moodle/commit/2108ac8a4faf18b37d14dd14a77b0d262eba67f2 too.

TIA,
Matteo

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

It was set to no security, I think LOGIN as authentication type and no mentioning of a port.

It ran fine until the upgrade to 3.0. I can imagine that the change you pointed out was included in 2.9.

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

TNX Koen for the feedback!

I'm pretty sure that disabling the auto-TLS feature should be (part of) the fix: I'll create a test bed on my dev server.

Would you mind to double check it?
The code here should be skipped in your case after applying the simple patch and no STARTTLS should appear in your debug logs... I actually do not understand why you were not successful.

TIA,
Matteo

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Koen,


thanks for providing your solution, elegant or not. I'll try to implement it.... but if you have time I'd need a little help (I'm not as technical as you are, sorry smile.


I've  no idea of how to follow your last line:

"On the mailserver (postfix) I added the server IP to mynetworks and added smtpd_sasl_exceptions_networks = $mynetworks to main.cf"

Do you think that is possible to explain it in basic steps or it is too problematic if I'm not an expert?

Thanks in any case for your reply and help!


p.s. just to be fair, I've posted this further request after having read about postfix and looking around to understand your suggestion smile I swear I tried but I do not have the techinical skill to go ahead by my own right now smile Thanks in any case



 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Franco,
could you give disabling the new PHPMailer feature a try before changing your initial settings?

TIA,
Matteo

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Matteo,


sure I'll be more than happy to give it a try.... just I've no idea how to do it smile -sorry again, not very technical skiils here-.

If you quickly explain me in which file to make the changes and what exactely to copy there (and where)... I'll do the test and report here back the result.

Sorry again to bother you with baby-steps... but I simply have no idea how to do it smile If you have no time to explain in details I understand, so do not worry and thanks in any case!


Fra

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Franco,
here are the steps:

  1. create a backup of the file lib/phpmailer/moodle_phpmailer.php just to go back if anything will go wrong
  2. open the file with a text editor
  3. find the line containing $this->CharSet   = 'UTF-8';
  4. add the two lines in my post below the line above: there, in my post, the new lines are prepended with a "plus" to show (unified diff) that the lines should be added in that place

At the end, in your file the "plus" shouldn't be added i.e. the code in the file should be:

         $this->Version   = 'Moodle '.$CFG->version;         // mailer version
         $this->CharSet   = 'UTF-8';
        // Disable the automatic TLS encryption added in v5.2.10.
        $this->SMTPAutoTLS = false;

         if (!empty($CFG->smtpauthtype)) {

and the green ones are the new lines.

TIA,
Matteo

 
Average of ratings: Useful (1)
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Matteo,


first of all thanks for your time and support, I really appreciate it!

I've done as you instructed and I completed the procedure you described. However there is still no email sent, still same problem...

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

OK, that's strange since in your past attempt the last lines showed an issue with the "automatic" STARTTLS:

2015-12-12 19:10:25    SERVER -> CLIENT: 250-srv.hdedi-xl400.org Hello srv.hdedi-xl400.org [109.203.111.116]
                                         250-SIZE 52428800
                                         250-8BITMIME
                                         250-PIPELINING
                                         250-AUTH PLAIN LOGIN
                                         250-STARTTLS
                                         250 HELP
2015-12-12 19:10:25    CLIENT -> SERVER: STARTTLS
2015-12-12 19:10:25    SMTP -> get_lines(): $data is ""
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "220 TLS go ahead
                                         "
2015-12-12 19:10:25    SERVER -> CLIENT: 220 TLS go ahead
2015-12-12 19:10:25    SMTP Error: Could not connect to SMTP host.
2015-12-12 19:10:25    CLIENT -> SERVER: QUIT
2015-12-12 19:10:25    SMTP -> get_lines(): $data is ""
2015-12-12 19:10:25    SMTP -> get_lines(): $str is  "

Could you share the debug output of the SMTP conversation, in a Preformatted style to help the reading?
To test the email sending you could even use https://moodle.org/plugins/local_mailtest, if you prefer.

TIA,
Matteo

 
Average of ratings: Useful (1)
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

Oh, that would be a good one to include as a standard module!

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Koen,
FYI, MDL-13745.

HTH,
Matteo

 
Average of ratings: Useful (1)
Picture of Bret Miller
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

And if you really would like to see an enhancement like this, it helps to create a Moodle Tracker account and vote. Sometimes things don't get done because it seems like there isn't sufficient interest.

MDL-13745

 
Average of ratings: Useful (1)
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Franco,
any chance to post the debug output (see here for your convenience) after you've modified the code with the two lines above?

TIA,
Matteo

 
Average of ratings: Useful (1)
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Matteo,


thanks a lot for your help. I'm just in the middle of a crazy week... I'm sorry for the delay, I'm planning to test it again and for sure to report it here during the weekend. If I can do it ealrier, I'll do it!


Thanks again, I really appreciate your support!

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Hi Matteo,

again thanks a lot for your support and patience!

I have a great news: Moodle now successfully sends email! Your two lines of code in moodle_phpmailer.php fixed it, thank you so much!

It seems that the previous time I followed your instruction I did a different mistake (instead of having my standard and working SMTP settings, I left a Moodle email setting that I was attempting out of frustration... and that clearly was not working), that's why your fix didn't immediately solve my problem. Instead now I rechecked everything twice... and you made my day!

Thanks a lot! For me the problem is solved!  Thanks again both for providing the solution and for explaining to me how to implement it. Have a great day!


 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Hi Franco,
great news: I was pretty sure that in some circumstances that should fix the issue.

Have a nice week-end too,

Matteo

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

Thanks to you my week end is already great (not spending it to reset the password of all the students forgetting their password :D). Seriously, thank you!

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersParticularly helpful MoodlersPlugin developers

Eh eh... you're welcome!

Thanks to Koen too big grin!

HTH,
Matteo

 
Average of ratings: -
Picture of koen roggemans
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTranslators

Hi Franco,

You need to be administrator on your mailserver and you need to have the right to change the configuration files on your server.

One of the postfix configuration files is main.cf. There is a variable in there, called $mynetworks. You can use this to make a list of trusted networks - usually only localhost is trusted wink.

With the  smtpd_sasl_exceptions_networks entry, you can define the networks that don't have to provide authentication details to be allowed to send mail. A dangerous setting. I set it that $mynetworks (including my Moodle server) are allowed to send mail without providing authentication details.

 
Average of ratings: Useful (1)
Yes, that's me
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Particularly helpful MoodlersPlugin developers

Thank your Koen, your solution helped us avoiding a long journey of trouble.

 
Average of ratings: -
Picture of Franco Bo
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

It could be something there n PHPmailer...

But, Just to rull out hypotesis, I have also tried to use TLS settings and it still doesn't work with moodle 3.0


Brainstorming, trying to understand where the problem is: why so few users have this problem? (it doesn't seem that a lot of people are writing in this or other forums about this issue). Maybe the problem is in some specific setting somewhere that we share and the majority of the users do not. Or we have just to wait till the beginning of next semester :D

 
Average of ratings: -
Picture of Marina Glancy
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
Core developersMoodle HQParticularly helpful MoodlersPlugin developersTesters
Hi, thanks for raising this post.

An issue has been created in Moodle tracker: MDL-52637

If you find how it can be configured or fixed on Moodle side, please leave a comment on the issue too.

TIA

 
Average of ratings: -
Picture of R Ali
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

I have the same problem using Moodle 3.0. Email not being generated for password recovery and new user registration.

Since I am on a localhost, I thought once I upload onto a web server, the problem might be resolved. I guess possibly not.

I usually leave out the SMTP configuration preferring the Moodle internal mailer.

I have used Moodle 7 and 8 without this problem. It looks Iike I might have to downgrade to either of the two then.

Thanks for highlighting this...



 
Average of ratings: -
Picture of Steve Fister
Re: SMTP problem with Moodle 3.0 (Build: 20151116)
 

I am currently seeing this same problem. The fix is already in my moodle code.


// MDL-52637: Disable the automatic TLS encryption added in v5.2.10 (9da56fc1328a72aa124b35b738966315c41ef5c6).

        $this->SMTPAutoTLS = false;

Are there any other potential issues which anyone has seen here?

 
Average of ratings: -