3

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' => 'username@gmail.com',
            'password' => 'mypassword'
        );

$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$sendNow   = $mail->setBodyHtml($message)
                  ->setFrom('username@gmail.com', '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

Dibya Sahoo
  • 839
  • 3
  • 9
  • 30
biswa
  • 56
  • 1
  • 1
  • 6

2 Answers2

7

Here is my code for zend mail.....

    $config = array('ssl' => 'tls',
                'auth' => 'login',
                'username' => 'your@gmail.com',
                'password' => 'password');

    $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

    $mail = new Zend_Mail();
    $mail->setBodyHtml($bodytext);
    $mail->setFrom('your@gmail.com');
    $mail->addTo($email, $username);
    $mail->setSubject('Profile Activation');
    $mail->send($transport);

And it is working now properly...

shruti
  • 780
  • 9
  • 25
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'.