Unable to send email in Zend using gmail SMTP. Getting Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception'. How to fix this?
12,170
Solution 1
Here is my code for zend mail.....
$config = array('ssl' => 'tls',
'auth' => 'login',
'username' => '[email protected]',
'password' => 'password');
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$mail = new Zend_Mail();
$mail->setBodyHtml($bodytext);
$mail->setFrom('[email protected]');
$mail->addTo($email, $username);
$mail->setSubject('Profile Activation');
$mail->send($transport);
And it is working now properly...
Solution 2
Your configuration for Gmail is set up differently to mine. Here's what I use:
$config = array(
'host' => 'smtp.gmail.com',
'port' => 587,
'ssl' => 'tls',
'auth' => 'login',
'username' => '*****',
'password' => '*****',
);
Note the differences in 'ssl' and 'port'.
Author by
biswa
Updated on June 09, 2022Comments
-
biswa almost 2 years
I am trying to send email using Gmail SMTP. Following is my code.
$mail = new Zend_Mail(); $config = array( 'ssl' => 'ssl', 'port' => '465', 'auth' => 'login', 'username' => '[email protected]', 'password' => 'mypassword' ); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config); $sendNow = $mail->setBodyHtml($message) ->setFrom('[email protected]', 'abc def') ->addTo($recipient) ->setSubject($subject) ->send($transport);
But the following error occurs. How can make it done?
Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Unable to find the socket transport 'ssl' - did you forget to enable it when you configured PHP?' in Implementation\trunk\webapp\library\Zend\Mail\Protocol\Abstract.php:277