我正在尝试使用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
答案 0 :(得分:7)
这是我的邮件代码.....
$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);
它现在正常运作......
答案 1 :(得分:2)
您的Gmail配置设置与我的不同。这是我使用的:
$config = array(
'host' => 'smtp.gmail.com',
'port' => 587,
'ssl' => 'tls',
'auth' => 'login',
'username' => '*****',
'password' => '*****',
);
请注意'ssl'和'port'的差异。