![](/img/trans.png)
[英]Zend Framework - Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception'
[英]Unable to send email in Zend using gmail SMTP. Getting Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception'. How to fix this?
我正在嘗試使用 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);
但是出現以下錯誤。 怎樣才能做到?
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
這是我的 Zend 郵件代碼.....
$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);
它現在工作正常......
您的 Gmail 配置設置與我的不同。 這是我使用的:
$config = array(
'host' => 'smtp.gmail.com',
'port' => 587,
'ssl' => 'tls',
'auth' => 'login',
'username' => '*****',
'password' => '*****',
);
請注意“ssl”和“port”的區別。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.