使用php,gmail和swiftmailer发送电子邮件会导致与SSL相关的错误
-
27-10-2019 - |
题
这是我的PHP代码: 通用标签
这是错误:
( ! ) Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php on line 233
( ! ) Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? #44551400]' in C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php on line 235
( ! ) Swift_TransportException: Connection could not be established with host smtp.gmail.com [Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? #44551400] in C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php on line 235
问题出在哪里?
更新:
我检查了phpinfo()
,它说:
通用标签
我引用了下面的链接,但是我无法安装ssl ...
解决方案
您的PHP是否支持SSL? http://php.net/manual/en/function.fsockopen.php ,然后检查 http://www.php.net/manual/en/openssl。installation.php 供参考。
使用创建页面 通用标签
是否启用了SSL?
其他提示
我正在寻找类似的问题,但我发现您必须编辑php.ini文件 编辑以下行 通用标签
删除半冒号,它将正常工作
希望对其他人有帮助:)
gmail需要在您的config.yml中使用
swiftmailer: 加密:tls
或替换您的: -> setEncryption('ssl') 通过 -> setEncryption('tls')
而不是SSL
您应该从php扩展名启用php_openssl模块。只需编辑您的 php.ini 文件 通用标签
实际上,我建议在端口25上使用tls 使用以下语法进行测试: 通用标签
您需要配置php以与ssl一起使用
我希望您已经解决了您的问题,但是对我来说,系: 通用标签
在我的php.ini中不存在(在Win7上运行XAMPP 1.7.7), 因此,只需继续并将其添加到扩展部分,然后从其中删除分号即可。