Magento – Magento SMTP TLS error

PHPphp-5.6smtp

I cant for the life of me figure out what the issue is with Magento using SMTP Pro connecting to gmail in google apps to send email from the site to customers. HTTPS on the site works if that makes any difference. I suspect some disconnect between openssl and php 5.6.

The Error I receive from SMTP Pro when running Self Test
" SMTP Pro Self Test Results
Sending test email to your contact form address: info@mysite.com from: admin@mysite.com. Unable to send test email.
Exception message was: Unable to connect via TLS
Please check the user guide for frequent error messages and their solutions.
Default templates exist.
Email communications are enabled."

the config looks like:

Other logs from Magento are:

"ERR (3): 
exception 'Zend_Mail_Protocol_Exception' with message 'Unable to connect via TLS' in /var/www/html/mysite.com/lib/Zend/Mail/Protocol/Smtp.php:211
Stack trace:
#0 /var/www/html/mysite.com/lib/Zend/Mail/Transport/Smtp.php(200): Zend_Mail_Protocol_Smtp->helo('localhost')
#1 /var/www/html/mysite.com/lib/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail()
#2 /var/www/html/mysite.com/lib/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#3 /var/www/html/mysite.com/app/code/local/Aschroder/SMTPPro/controllers/Smtp/TestController.php(136): Zend_Mail->send(Object(Zend_Mail_Transport_Smtp))
#4 /var/www/html/mysite.com/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Aschroder_SMTPPro_Smtp_TestController->indexAction()
#5 /var/www/html/mysite.com/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#6 /var/www/html/mysite.com/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#7 /var/www/html/mysite.com/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#8 /var/www/html/mysite.com/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#9 /var/www/html/mysite.com/index.php(83): Mage::run('', 'store')
#10 {main}"

AND one more:

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed  in /var/www/html/mysite.com/lib/Zend/Mail/Protocol/Smtp.php on line 206

Line 206 of the mentioned file is:

// If a TLS session is required, commence negotiation
if ($this->_secure == 'tls') {
    $this->_send('STARTTLS');
    $this->_expect(220, 180);
    if (!stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
        /**
         * @see Zend_Mail_Protocol_Exception
         */
        #require_once 'Zend/Mail/Protocol/Exception.php';
        throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS');
    }
    $this->_ehlo($host);
}

$this->_startSession();
$this->auth();

Hoping someone out there know more than I do on this stuff. Thanks for any help/guidance that comes in

Best Answer

The error you are getting from OpenSSL indicates that the SSL extension of PHP is compiled and loaded so no need to compile or load any .so or .dlls.

This is most likely a CA verfication issue - your SSL client (in this case PHP) is trying to verify the server's authenticity using root certificates; That's good - the only problem is this fails. Usually this means one of two things:

  1. The server does not present a valid SSL certificate; This is unlikely for a well established email provider, I'm guessing you're using Google so this is probably not the issue.

  2. More likely, your server does not have the up-to-date root certificates installed, or PHP does not know where they are. This is a configuration issue and solving it differs from server to server depending on your Linux distro and on how you installed PHP (e.g. from source, distro packages etc.). If you can provide more details about that, it may be possible to help.

Related Topic