SMTP Error: Could not authenticate.

SMTP Error: Could not authenticate.

by Jason De Donno -
Number of replies: 5

Hi

Moodle 2.2, Ubuntu.

Having finally set up an SMTP server, I entered the server name and authentication in the appropriate fields in Moodle, only to get this error message:

SMTP Error: Could not authenticate.

I've tested the SMTP server and it's working fine. I've double checked the name and password and everything is right. 

So what could the problem be?

Average of ratings: -
In reply to Jason De Donno

Re: SMTP Error: Could not authenticate.

by Paul Lovatt -

Quite a few people have this problem.  For 1and1.co.uk customers we have discovered (another thread) that if we leave the fields empty the emails will go out normally, provided the cron is properly set up.  i.e. enter nothing at all and the default php method for 1and1 seems to be working fine.

I have noticed lots of users of other hosting companies saying that they have trouble getting the moodle to send out but I don't know if they have found solutions for their servers.

In reply to Paul Lovatt

Re: SMTP Error: Could not authenticate.

by Jason De Donno -

Thanks for the reply. I ought to have posted this in the email area :/

But this is frustrating - our site is handicapped without email. I'm using AWS (Amazon Web Services) for the Linux moodle hosting server using the EC2 service,  and also a seperate SMTP server using the SES service.

/Jason

In reply to Jason De Donno

Re: SMTP Error: Could not authenticate.

by Paul Lovatt -

Hi Jason,

Are you absolutely sure your site does not send email with the fields left completely empty (using the default php method)?  Try it. it might do you until you find a better solution.

In reply to Paul Lovatt

Re: SMTP Error: Could not authenticate.

by Jason De Donno -

I've no idea how empty fields would affect it or how to change or check this. I don't even now how to flush those pending emails out of the system and try with new ones.

But since the problem seems to be authentication then I would imagine that the content of the mail is irrelevant. Without passing authtication, the SMTP server cannot receive, and therefore not read, the information that Moodle wants to send.

I did notice that SMTP at Amazon uses TLS security, which might be the reason why the authentication isn't working. If the username and password sent by Moodle are encoded according to a different set of rules than the the SMTP server is using, then it will not work.

But I see no way to test this. There is no option in Moodle to specify the security used for email, nor anyway at Amazon to disable the TSL security used there.

In reply to Jason De Donno

Re: SMTP Error: Could not authenticate.

by Jason De Donno -

I found it. This appears to be an issue that is unresolved, at least in Moodle 2.2.

If an SMTP server forces the use of TSL protocol, there is no way to enter this in the email plugin settings in Moodle. Therefore you have to add this information directly to the code in a Moodle php file.

There is a mention in the tracker about here: http://tracker.moodle.org/browse/MDL-30960

In moodle 2.2, you have to find the get_mailer function in /lib/moodlelib.php

Then, after the line:

$mailer->IsSMTP();

add the following:

$mailer->SMTPSecure = "tls";

This tells Moodle to use the tls protocol. A simple check box on the email settings of Moodle would solve this, without having it to get all messy. A very easy fix.

/Jason