Laravel 5.5:无法通过谷歌发送电子邮件(SSL操作失败)

时间:2018-02-03 00:22:38

标签: php laravel

我在类似问题的答案中看到了.env的波纹管设置:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=somePassword1234
MAIL_ENCRYPTION=tls

然而,没有任何作用。使用tls加密,我收到了错误

stream_socket_enable_crypto(): SSL operation failed with code 1. 
OpenSSL Error messages: error:14090086:SSL routines:
ssl3_get_server_certificate:certificate verify failed

使用ssl加密,我收到错误:

Swift_TransportException
Expected response code 220 but got code "", with message ""

2 个答案:

答案 0 :(得分:3)

您必须使用配置邮件文件中的证书禁用对该字母的签名:<wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" wsu:Id="UserNameWSTrustBinding_IWSTrust13Async_policy"> <wsp:ExactlyOne> <wsp:All> <sp:SupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/"> <wsp:Policy> <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> <wsp:Policy></wsp:Policy> </sp:UsernameToken> </wsp:Policy> </sp:SupportingTokens> </wsp:All> </wsp:ExactlyOne> </wsp:Policy>

mail.php

有关此错误以及chek的更多信息 - link

  

编辑注释 :禁用SSL验证会产生安全隐患。如果不验证SSL / HTTPS连接的真实性,恶意攻击者可以冒充受信任的端点(例如GitHub或其他一些远程Git主机),并且您将容易受到Man-in-the-Middle Attack的攻击。 在将此作为解决方案使用之前,请确保完全了解安全问题。

答案 1 :(得分:0)

这是Ilya答案的补充。从此回答中添加设置后,需要从Google帐户信息中心设置file(GLOB CONFIGURATION_DATA ${PROJECT_SOURCE_DIR}/data/configurations/*) foreach(data ${CONFIGURATION_DATA}) #only copy if file doesnt exists if(NOT EXISTS ?? how to get same path as - $<TARGET_FILE_DIR:${PROJECT_NAME_STR}>/data/configurations) ) add_custom_command(TARGET ${PROJECT_NAME_STR} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${data} $<TARGET_FILE_DIR:${PROJECT_NAME_STR}>/data/configurations) endif() endforeach()

https://blog.laravelmade.com/sending-emails-with-laravel-5-gmail/

我想,最好在测试结束后再次禁用此设置。

相关问题