SMTP Error: Could not authenticate.

Reported by leonelvsc on 2010-11-03

This bug report was converted into a question: question #132474: SMTP Error: Could not authenticate..

6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Medium
Ruslan Kabalin

Bug Description

I set this on my config.php and config-defaults.php on the lib folder file

$cfg->smtphosts = 'smtp.gmail.com';
// If you have specified an smtp server above, and the server requires authentication,
// enter them here
$cfg->smtpuser = '<email address hidden>';
$cfg->smtppass = '**************************';

any ideas?

leonelvsc (leonel-vsc) on 2010-11-03
Changed in mahara:
status: New → Invalid
Changed in mahara:
status: Invalid → Confirmed
assignee: nobody → Ruslan Kabalin (ruslan-kabalin)
importance: Undecided → Low
Ruslan Kabalin (rkabalin) wrote :

It is a bug. In order to communicate with smtp.gmail.com, 'SMTPSecure' parameter in phpmailer has to be set either to 'ssl' (and smtp port set to 465) or 'tls' (and port set to 587). Currently SMTPSecure is not configured through mahara configuration file.

Will fix this on master in a moment.

For more information see:
   http://mail.google.com/support/bin/answer.py?hl=en-GB&ctx=mail&answer=75726
   htdocs/lib/phpmailer/docs/use_gmail.txt

Changed in mahara:
status: Confirmed → Fix Committed
Ruslan Kabalin (rkabalin) wrote :

In order to use gmail smtp server, in addition to the general settings, secure connection protocol has to be defined:

use either:
   $cfg->smtpsecure = 'ssl';
   $cfg->smtpport = 465;
or
   $cfg->smtpsecure = 'tls';
   $cfg->smtpport = 587;

Once the fix is populated to stable versions, it definitely worth mentioning it in Installation Troubleshooting wiki page.

François Marier (fmarier) wrote :

Thanks for sorting that out Ruslan. That's a very handy patch for people to apply on their sites if they're affected by this problem.

Maybe we need to rethink a bit how we handle mail servers. What I mean by that is that clearly we need to include more options than just the name of an SMTP server:

- ssl or tls
- port number
- username/password (for those servers that require authentication)

So I think that it's probably time to change our simplistic comma-separated list of SMTP hosts to perhaps an array of arrays.

I'm thinking something along the lines of:

$cfg->smtphosts = array(array('server' => 'smtp.gmail.com', 'port' => 587), array('server' => 'localhost'));

but we should also make sure we are backwards-compatible and support the old:

$cfg->smtphosts = 'smtp.example.com,localhost';

and also _maybe_ a simplified form like:

$cfg->smtphosts = array(array('server' => 'smtp.gmail.com', 'port' => 587), 'smtp.example.com');

Of course, with confoptions becoming more complicated, maybe it's time to think of moving this to a proper UI under site administration. What do you think?

François Marier (fmarier) wrote :

And just to be clear, I'm certainly not criticising the approach you took since it's very much in line with how we've done things in the past with smtpuser and smtppass for example :)

I was simply pointing out that it might be time to refactor our mail settings a bit to make more useful.

Ruslan Kabalin (rkabalin) wrote :

I see what you mean Francois. I think moving SMTP settings to UI as default place for new user where smtp should be configured is better than configuration line with nested arrays, which might be too complicated for inexperienced user. But for possibility of dynamic configuration changes we should support configuration file smtp settings as well. So, I suggest to implement all what you mentioned: config line with multidimensional array, backward compatibility with old syntax and UI under site adm ;)) We might aim this to version 1.4.

Changed in mahara:
status: Fix Committed → In Progress
milestone: none → 1.4.0
Changed in mahara:
importance: Low → Medium
Ruslan Kabalin (rkabalin) wrote :

I had a more detailed look at phpmailer, and it looks like the idea of using multiple host smtp settings in array (e.g. $cfg->smtphosts = array(array('server' => 'smtp.gmail.com', 'port' => 587, user='someuser', password='somepass'), array(...)) ) will not work unless we do host connectivity valudation outside phpmailer methods. Point is that, while it expects that 'smtphosts' may contain semicolon-separated list of hosts, all other parameters (port if specified separately, username, password, SMTPsecure) are assumed to be the same for all listed hosts (see class.phpmailer.php, line 783 onwards).

Given above, I suggest to leave config.php mail-related parameters as they are now (not extending it to nestled array) and implement mail configuration interface to the current mail settings as we agreed at bug #132474.

François Marier (fmarier) wrote :

Fair enough, I guess we'll just have to live with this limitation of phpmailer.

Thanks for looking into this Ruslan!

Changed in mahara:
status: In Progress → Fix Committed
Changed in mahara:
status: Fix Committed → Fix Released
tags: added: email smtp

Reviewed: https://reviews.mahara.org/309
Committed: http://gitorious.org/mahara/mahara/commit/183febb62c40b3e378584f9b1525cd8eb6a8a387
Submitter: Francois Marier (<email address hidden>)
Branch: master

commit 183febb62c40b3e378584f9b1525cd8eb6a8a387
Author: Ruslan Kabalin <email address hidden>
Date: Fri Jun 10 17:24:41 2011 +0100

    Add comments that email configuration has an interface (bug #670683)

    Change-Id: I24add4bd46bc4ddd2649cf9c7ce281072879ed4a
    Signed-off-by: Ruslan Kabalin <email address hidden>

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related questions