无法通过smtp在zend for gmail中发送电子邮件

时间:2014-03-25 12:32:04

标签: zend-framework

       $config = array('ssl' => 'tls',
            'port' => 587,
            'auth' => 'login',
            'username' => '****@gmail.com',
            'password' => '****');
        $tr = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
        $mail = new Zend_Mail();
        $mail->setBodyText($this->_request->getPost('body'));
        $mail->setFrom('****@gmail.com');
        $mail->addTo($this->_request->getPost('to'), 'receiver1');
        $mail->setSubject('TestSubject');

        if ($mail->send($tr))
            echo "Mail Sent Successfully";
        else
            echo "Mail was not sent";

我收到此错误消息:

消息:无法通过TLS连接

1 个答案:

答案 0 :(得分:0)

您需要在PHP中使用SSL扩展。

转到服务器上的php.ini文件,找到extension=php_openssl.dll并取消注释