1. 使用laravel
默认邮件服务发送邮件,本地测试正常,但是 上线后,莫名其妙的错误如下:
SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Connection could not be established with host[ #0]
2. 这种问题是swiftmailer
默认的一个bug,因为线上会检查ssl。解决办法vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php 266行添加代码修改后如下所示:
if (isset($this->params['stream_context_options'])) {
$options = array_merge($options, $this->params['stream_context_options']);
}
//TODO bug 此行和以下2行是新加的,解决问题就加下边两行就行
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
3. 以下是github
原文出处