无法使用zend连接到gmail smtp

时间:2016-04-22 05:03:11

标签: php email zend-framework smtp

我正在尝试使用Zend Smtp发送电子邮件。

我已经使用zend和google的凭据配置了所有内容。

当我尝试发送邮件时,我收到此错误。

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

我不确定我做错了什么。谁能帮我吗。这是我的代码。

IndexController.php

public function indexAction()
{
    $mail = new Zend_Mail();
                $mail->addTo('chaitanya5a2@gmail.com', 'Chaitanya Kanuri')
                     ->setFrom('chaitanya@gmail.com', 'Myself')
                     ->setSubject('My Subject')
                     ->setBodyText('Email Body')
                     ->send();

        }  

bootstrap.php中

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initDefaultEmailTransport() {
        $emailConfig = $this->getOption('email');

        $smtpHost = $emailConfig['transportOptionsSmtp']['host'];
        unset($smtpHost);

        $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $emailConfig['transportOptionsSmtp']);

        Zend_Mail::setDefaultTransport($mailTransport);
    }
}

的application.ini

email.transportOptionsSmtp.host     = "smtp.gmail.com"
email.transportOptionsSmtp.auth     = "login"
email.transportOptionsSmtp.username = "mygmail@gmail.com"
email.transportOptionsSmtp.password = "mygmailpassword"
email.transportOptionsSmtp.ssl      = "ssl"
email.transportOptionsSmtp.port     = 465

提前致谢。

0 个答案:

没有答案