小编bis*_*swa的帖子

使用gmail SMTP的Zend电子邮件

我正在尝试使用gmail SMTP发送电子邮件.以下是我的代码.

$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);
Run Code Online (Sandbox Code Playgroud)

但是发生以下错误.怎么能完成它?

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

php zend-framework zend-mail

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×1

zend-framework ×1

zend-mail ×1