Try to send transactional mail through my mail server via port 587 using TLS authentication.
Connection variables verified as correct
Mail sent to client
SMTP Error: Could not connect to SMTP host.
Ubuntu Server 16.04, Apache2, PHP Version 7.0.4-7ubuntu2, Joomla 3.5., MariaDB 10
Self signed SSL certificate
For some reason Joomla refuses to negotiate TLS. I installed AcyMailing and set up a mail list of 10 recipients and it sent all 10 mails instantly. On install AcyMailing must have imported the authorization credentials from Joomla as they were already in place when I checked the configs. Not sure what this could be. I asked on Joomla regular forums and received no logical answers so I figured it was time to ask here.
As an update I tried sending SMTP via a Gmail account and it also failed.
We self host from Panama City Panama and our mail server is in a colo in Houston. 587 definately works as AcyMailing uses the same settings and works fine. In fact it imported them from Joomla on installation. It is something in Joomla as it will also not authenticate with Gmail. I looked at the mail logs on the server in Texas and they fail when Joomla attempts TLS. I'll have to take a look at the difference between the data Joomla and AcyMailing sends. If I can't get this solved it will be a major deal breaker for our small company. No transactional email means we can sign up new members. We already have quite an investment in 3rd party components and to start from scratch with another CMS would effectively put us out of business.
Labels |
Added:
?
|
Joomla uses PHPMailer to send e-mails.
Check https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
It seems that if I am having this problem and have been able to replicate it on 2 servers perhaps there is a bug. Perhaps instead of pushing the blame off on PHPmailer maybe someone on the development team needs to look at the specifics of my request and see if they can replicate it. I have been using Joomla since before it was Joomla... Remember Mambo? I have never had reason to suspect that I had encountered a bug as so many people were working with Joomla by the time I ran across something it was already documented.
Ubuntu 16.04 server
PHP Version 7.0.4-7ubuntu2
Joomla 3.5.1
MariaDB 10
Remember please this version of Ubuntu is the newly released LTS. Maybe I am one of the first adopters of it and maybe it is a bug specific to it.
I have run across posts where there was an SMTP connection issue when Joomla moved to 3.5. Well one should not rule out the possibility that there is still a real problem that just may need addressed.
Here is how I debugged the issues I had with smtp. Go to the JMail class and comment out this line in the constructor:
// Configure a callback function to handle errors when $this->edebug() is called
$this->Debugoutput = function ($message, $level)
{
JLog::add(sprintf('Error in JMail API: %s', $message), JLog::ERROR, 'mail');
};
This line should actually help store the error messages in the log, but I couldn't find where, so I just uncommented them.
Now go in libraries\vendor\phpmailer\phpmailer\class.phpmailer.php and look for those lines:
/**
* The SMTP server timeout in seconds.
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
* @var integer
*/
public $Timeout = 300;
/**
* SMTP class debug output mode.
* Debug output level.
* Options:
* * `0` No output
* * `1` Commands
* * `2` Data and commands
* * `3` As 2 plus connection status
* * `4` Low-level data output
* @var integer
* @see SMTP::$do_debug
*/
public $SMTPDebug = 0;
set smtpdebug to 2. Timeout to 10 (this way you'll have to wait less when you try to send).
Now create a script that uses JMail to send a mail and die after it. For example:
error_reporting(-1);
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$sender = array(
$config->get( 'mailfrom' ),
$config->get( 'fromname' )
);
$mailer->setSender($sender);
$user = JFactory::getUser();
$recipient = $user->email;
$mailer->addRecipient($recipient);
$body = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
$mailer->setSubject('Your subject string');
$mailer->setBody($body);
$send = $mailer->Send();
die();
The smtp class should now output messages on the screen that should give you enough information to figure out what's going on.
Compojoom... Thanks for a nudge in a positive direction. I'll certainly follow your advice and hopefully will be able to find a solution. It seems strange to me that it only started occurring when I switched from CentOS 6.7 to Ubuntu 16.04. Maybe I should have stayed on Ubuntu's earlier release.
This line should actually help store the error messages in the log, but I couldn't find where, so I just uncommented them.
If you don't have a JLog logger enabled catching messages in the "mail" category (easiest thing is to turn on the option in the debug plugin or add a JLog::addLogger()
call somewhere to set that up since Joomla by default enables logging for very few categories) those will get ignored.
@mbabker - aaaaah. It took me an hour to figure out why phpmailer's smtp class was not outputing the debug messages and previously on 3.5 it was... In the debug plugin the categories description says: "If empty all categories will be shown" - then I don't understand why I didn't see the errors.
Before 3.5.1 the handler for PHPMailer's edebug()
method was using their inbuilt default of echoing stuff out, we made the change to be able to capture that in our logging API instead.
Category | ⇒ | Components Front End |
It seems that if I am having this problem and have been able to replicate it on 2 servers perhaps there is a bug. Perhaps instead of pushing the blame off on PHPmailer maybe someone on the development team needs to look at the specifics of my request and see if they can replicate it.
Don't know who blamed PHPMailer.
Their troubleshooting guide helps to debug problems with SMTP mail configurations and explains why many of those problems happens and how to solve them.
Same problem here.. im trying gmail and zohomail.. trying all port seems the problem still exist..
hope someone put attention on it.. now using phpmail for backup.. which come to spam :(
Problem resolved. Installed ssl cert from letsencrypt on mail server for testing. Soon as it had a valid cert smtp worked perfectly. It appears that Joomla won't accept self signed certs.
Please mark RESOLVED.
Sorry for taking my time to get back on this. Was tied up with construction of a data center for a few days.
Closed as requested - glad you worked it out
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-06-28 11:08:12 |
Closed_By | ⇒ | brianteeman |
It appears that Joomla won't accept self signed certs.
it's php 5.6+ openssl extension default behaviour. See http://php.net/manual/en/migration56.openssl.php
Please delete the spam
What's your hosting company? Setting up transaction email through smtp has been proved to be a pain in *** with most hosting companies as they block 587 for outgoing connections unless you connect to their own smtp server.