我正在尝试使用Gmail SMTP发送电子邮件。以下是我的代码。
$mail = new Zend_Mail();
$config = array(
'ssl' => 'ssl',
'port' => '465',
'auth' => 'login',
'username' => '[email protected]',
'password' => 'mypassword'
);
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$sendNow = $mail->setBodyHtml($message)
->setFrom('[email protected]', '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' => '[email protected]',
'password' => 'password');
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$mail = new Zend_Mail();
$mail->setBodyHtml($bodytext);
$mail->setFrom('[email protected]');
$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'的区别。