Connection could not be established with host smtp.gmail.com

Published 1 week ago by omarsow94

Every informations about my gmail account are OK, but the error still

config/mail.php

<?php

return [



    'driver' => env('MAIL_DRIVER', 'smtp'),

 

    'host' => env('MAIL_HOST', 'smtp.gmail.com'),

  

    'port' => env('MAIL_PORT', 587),


    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', '[email protected]'),
    ],

   

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

   
    'sendmail' => '/usr/sbin/sendmail -bs',

    

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

AND my .env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
Vijay
Vijay
1 week ago (9,680 XP)

Have you enabled allow less secure apps ( https://myaccount.google.com/lesssecureapps ) in gmail settings.

omarsow94

Yes @Vijay and config:cache too but i still have error

Vijay
Vijay
1 week ago (9,680 XP)

Try changing the mail driver:

MAIL_DRIVER=sendmail

and Try this too:

Use

MAIL_PORT=465 

and

MAIL_ENCRYPTION=ssl
omarsow94

Cool, We have e-mailed your password reset link! but i don't received email @Vijay

Vijay
Vijay
1 week ago (9,680 XP)

Check SPAM email.

omarsow94

It's done , i check but nothing @Vijay

Vijay
Vijay
1 week ago (9,680 XP)

Change only this setting

MAIL_DRIVER=smtp

and Keep this as it is:

MAIL_PORT=465 
MAIL_ENCRYPTION=ssl
omarsow94

still, i don't received mail @Vijay

Vijay
Vijay
1 week ago (9,680 XP)

Your configuration is good but I don't know why gmail host is not sending your emails.

Try this service provider:

mailtrap.io

omarsow94

mailtrap.io work on production ? @Vijay

Vijay
Vijay
1 week ago (9,680 XP)

This is only for testing purpose.

Vijay
Vijay
1 week ago (9,680 XP)

For gmail: Last option you can try: Allow Access to this:

https://accounts.google.com/DisplayUnlockCaptcha

biishmar

Your .env file should be like this,

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=gmailaddress MAIL_PASSWORD=yourpassword MAIL_ENCRYPTION=null

if u have enabled two factor authentication, create app key and use that as password..

if u face certificate error, paste the below code in config/mail.php at the end.

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

omarsow94

We have emailed you the password reset link! But i dont received mail . Someone can help me ?

Please sign in or create an account to participate in this conversation.