Question

I am trying to send email with gmail account in Zend framework. This is what I got so far:

$mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', array(
    'auth'     => 'login',
    'username' => 'myaddress@gmail.com',
    'password' => 'password',
    'port'     => '587',
    'ssl'      => 'tls',
));
Zend_Mail::setDefaultTransport($mailTransport);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('myaddress@gmail.com', 'sender');
$mail->addTo('reciever@gmail.com', 'receiver');
$mail->setSubject('TestSubject');
$mail->send();

With this code, I get the following error:

Message: Unable to connect via TLS

How can I fix it? I have a default XAMPP installation setup with no SMTP setup in php.ini.

Was it helpful?

Solution

I found the solution: I had a default php.ini setting setup by xampp. In order to connect via TLS, we require OpenSSL be enabled. To enable OpenSSL, first find php_openssl.dll file inside xampp\php\ext folder. If you find this file, then open php.ini file and add the following line to it:

extension=php_openssl.dll

That's all to enable openssl in xampp. this enabled to send email

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top