Laravel - Connection could not be established with host smtp.gmail.com [ #0]

后端 未结 13 771
无人及你
无人及你 2020-12-29 04:32

I\'m trying to send an email from Gmail using Laravel from localhost. I\'m getting this error: Connection could not be established with host smtp.gmail.com [ #0]

I\'

13条回答
  •  无人及你
    2020-12-29 04:57

    I had the same error: Connection could not be established with host smtp.gmail.com [ #0] and followed the steps outlined here: https://github.com/swiftmailer/swiftmailer/issues/544.

    Try adding the following lines to _establishSocketConnection() in Swift/Transport/StreamBuffer.php on line 263:

    $options['ssl']['verify_peer'] = FALSE;
    $options['ssl']['verify_peer_name'] = FALSE;
    

    Note that this is not a perfect solution as it involves: a) Hacking core code which may be overwritten in a SwiftMailer update, and b) decreases the security of your app as you're no longer validating the connection. But as a temporary work-around it worked for me.

提交回复
热议问题