【发布时间】:2017-03-15 15:42:30
【问题描述】:
升级到 php 5.6 (mac os x sierra) 后,我无法在本地测试环境中发送邮件。
但遗憾的是,在 Symfony 中通过 swiftmailer 发送邮件不起作用。
这是错误:
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
到目前为止我发现了什么:
由于 php 5.6 openssl 似乎是一个要求:http://php.net/manual/en/migration56.openssl.php
因为在更新之后我根本无法使用 file_get_contents 而没有这个错误,所以我所做的是指定一个 openssl.cafile= 在我在这里找到的 php ini 中:https://andrewyager.com/2016/10/04/php-on-macos-sierra-cant-access-ssl-data/
现在 file_get_contents 再次工作,但我无法通过 smtp 发送 swiftmailer 邮件。
这是我的 swiftmailer 配置:
swiftmailer:
transport: "smtp"
host: "smtp.gmail.com"
username: "%mailer_user%"
password: "%mailer_password%"
auth_mode: login
port: 587
encryption: tls
delivery_address: "%mailer_delivery_address%"
spool: { type: memory }
我必须在任何其他地方提供我的 cafile 到 symfony/swiftmailer 吗?
我已经找到了这个:PHP - Swiftmailer using STARTTLS and self signed certificates 但是硬编码这样的解决方案不是一种选择,因为我想部署代码库而不是每次都更改它。我更喜欢在系统层面解决这个问题。
【问题讨论】:
-
请说明您使用的 OpenSSL 版本。还请显示设置 OpenSSL 使用的上下文的代码。它应该类似于 OpenSSL wiki 上的 SSL/TLS Client。
标签: php symfony swiftmailer pyopenssl