rockstar
rockstar

Reputation: 1328

Send email with gmail in Zend framework

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' => '[email protected]',
    '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('[email protected]', 'sender');
$mail->addTo('[email protected]', '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.

Upvotes: 4

Views: 2633

Answers (1)

rockstar
rockstar

Reputation: 1328

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

Upvotes: 6

Related Questions