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

后端 未结 13 776
无人及你
无人及你 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 05:04

    In Laravel project directory, edit config/mail.php and add the following:

    'stream' => [
            'ssl' => [
                'allow_self_signed' => true,
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        ]
    

    It worked for me.

    Fyi, my SMTP settings are:

    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=465
    MAIL_USERNAME=[Full Gmail Address]
    MAIL_PASSWORD=[Google App Password obtained after two step verification on Google Account Page]
    MAIL_ENCRYPTION=ssl
    

提交回复
热议问题