?
avatar elleonblanco
elleonblanco
23 May 2016

Steps to reproduce the issue

Try to send transactional mail through my mail server via port 587 using TLS authentication.
Connection variables verified as correct

Expected result

Mail sent to client

Actual result

SMTP Error: Could not connect to SMTP host.

System information (as much as possible)

Ubuntu Server 16.04, Apache2, PHP Version 7.0.4-7ubuntu2, Joomla 3.5., MariaDB 10
Self signed SSL certificate

Additional comments

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.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar elleonblanco elleonblanco - open - 23 May 2016
avatar elleonblanco elleonblanco - change - 24 May 2016
The description was changed
avatar compojoom
compojoom - comment - 24 May 2016

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.

avatar elleonblanco
elleonblanco - comment - 24 May 2016

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.

avatar brianteeman brianteeman - change - 24 May 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 24 May 2016

Joomla uses PHPMailer to send e-mails.

Check https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

avatar elleonblanco
elleonblanco - comment - 24 May 2016

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.

avatar compojoom
compojoom - comment - 24 May 2016

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.

avatar elleonblanco
elleonblanco - comment - 24 May 2016

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.

avatar mbabker
mbabker - comment - 24 May 2016

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.

avatar compojoom
compojoom - comment - 24 May 2016

@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.

avatar mbabker
mbabker - comment - 24 May 2016

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.

avatar zero-24 zero-24 - change - 24 May 2016
Category Components Front End
avatar andrepereiradasilva
andrepereiradasilva - comment - 24 May 2016

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.

avatar ilhamzulfikar
ilhamzulfikar - comment - 25 May 2016

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 :(

avatar elleonblanco
elleonblanco - comment - 3 Jun 2016

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.

avatar brianteeman
brianteeman - comment - 28 Jun 2016

Closed as requested - glad you worked it out


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10608.

avatar brianteeman brianteeman - change - 28 Jun 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-06-28 11:08:12
Closed_By brianteeman
avatar brianteeman brianteeman - close - 28 Jun 2016
avatar brianteeman brianteeman - close - 28 Jun 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Jun 2016

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

avatar brianteeman
brianteeman - comment - 14 May 2019

Please delete the spam

Add a Comment

Login with GitHub to post a comment