Connection could not be established with host smtp

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

I”m using ssl with port 465. I also tried 587 but it didn”t work.

Watching: Connection could not be established with host smtp

I also tried this but it didn”t work. I found a lot of people suffering from the same problems, but the solutions I found didn”t work.

*

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

“stream” => true, “verify_peer” => false, “verify_peer_name” => false, >, >It worked for me.

Fyi, my SMTP settings are:

MAIL_DRIVER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=465MAIL_USERNAME=MAIL_PASSWORD=MAIL_ENCRYPTION=ssl

I had the same error: Connection could not be established with host smtp.gmail.com 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 = FALSE;$options = 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.

*

This one line change in .env file will make it work

MAIL_DRIVER=sendmailIf it also has no effect try to switch between the mail port

MAIL_PORT=587Or

MAIL_PORT=465This will work only if you enable “Allow Less secure app access” under google account

*

In your .env file you will need to set the email address and password of your email account:

See Also:  How to Write a Resignation Letter (Examples Template!) | The Muse

MAIL_DRIVER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=test
gmail.comMAIL_PASSWORD=testpasswordand in mail.php

env(“MAIL_DRIVER”, “smtp”), “host” => env(“MAIL_HOST”, “smtp.mailgun.org”), “port” => env(“MAIL_PORT”, 587), “from” => “yourEmail
gmail.com”, “name” => “Your Title”>, “encryption” => “tls”, “username” => env(“MAIL_USERNAME”), “password” => env(“MAIL_PASSWORD”), “sendmail” => “/usr/sbin/sendmail -bs”, “pretend” => false,>;and clear the config cache with:

php artisan config:cache
here”s what is working with me

MAIL_MAILER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=MAIL_PASSWORD=MAIL_ENCRYPTION=tlsif you are two auth verification with your account , should be generate new app password and use into you env file. this is what working with me.

Have you tried changing the encryption to tls? I currently use a Gmail SMTP sever to send emails from my Laravel app. I use TLS and port 587
in localhost you can set your MAIL_DRIVER=smtp but on real server like cpanel you must to set MAIL_DRIVER=sendmail and edit your config/mail.php”default” => env(“MAIL_MAILER”, “sendmail”),but its not good idea because after you send mail on google you get error on gmail like this :

Be careful with this messageGmail could not verify that it actually came from tenetup.reminderme
For me, it turned out TripMode blocked nginx & php-fpm. So make sure no app like this or firewall is blocking the connection to the mail server.

Readmore: How To Enable Quickbooks To Send Emails With Avast Antivirus? ?

https://accounts.google.com/DisplayUnlockCaptchahttps://www.google.com/settings/security/lesssecureapps

env

MAIL_DRIVER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=test
If you are using Amazon EC2, do ensure to set outbound rules for SMTP (25) and SMTPS (465) to Anywhere.

See Also:  How to Fix Gmail If You're Not Receiving Emails

MAIL_MAILER=smtpMAIL_HOST=smtp.googlemail.comMAIL_PORT=465MAIL_USERNAME=yourgmailemail
On Cpanel changing only the MAIL_DRIVER to sendmail from smtp in .env works for me.

MAIL_DRIVER=sendmailMAIL_HOST=smtp.example.comMAIL_PORT=465MAIL_USERNAME=info
example.comMAIL_PASSWORD=passwordMAIL_ENCRYPTION=tlsMAIL_FROM_NAME=”${APP_NAME}MAIL_FROM_ADDRESS=info
this worked for me after a long search time, the best configuration :

“driver” => “smtp”,”host” => “smtp-mail.outlook.com”,”port” => 587, ( or 25)”encryption” => “tls”,
You can”t send emails from your localhost by default.

If you configure your files correctly, you would be able to send emails from it.

Readmore: Powerbot For Gmail Plugin For Chrome, Powerbot For Gmail Now Works With

You could also try to upload the site on an server or production zone. There it will work.

Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you’re looking for? Browse other questions tagged laravel-4 gmail or ask your own question.

In remote host: Connection could not be established with host smtp.gmail.com
Using gmail smtp via Laravel: Connection could not be established with host smtp.gmail.com

Categories: Mail

Leave a Reply

Your email address will not be published. Required fields are marked *