这是我的PHP代码:
function SendCookieToTheMail()
{
require_once 'swift-mailer/lib/swift_required.php';
//Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com')
->setPort(465)
->setEncryption('ssl')
->setUsername('007@gmail.com')
->setPassword('123')
;
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
//Create a message
$message = Swift_Message::newInstance('Test')
->setFrom(array('007@gmail.com' => 'From mr. 007'))
->setTo(array('007@gmail.com', '007@gmail.com' => 'To mr. 007'))
->setBody('Body')
;
//Send the message
$result = $mailer->send($message);
/*
You can alternatively use batchSend() to send the message
$result = $mailer->batchSend($message);
*/
}
这里是错误信息:
( ! ) 警告:fsockopen() [function.fsockopen]: 无法连接到ssl://smtp.gmail.com:465(无法找到套接字传输“ssl” - 配置PHP时是否忘记启用它?)位于C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php的第233行
( ! ) 致命错误:未捕获异常'Swift_TransportException',消息为“无法与主机smtp.gmail.com建立连接[Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? #44551400]”,位于C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php的第235行
( ! ) Swift_TransportException:无法与主机smtp.gmail.com建立连接[Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? #44551400] ,位于C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php的第235行
问题出在哪里?
更新:
我检查了
phpinfo()
,它显示:OpenSSL support disabled (install ext/openssl)
我参考了下面的链接,但是无法安装SSL...