我正在尝试使用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
提前致谢。