Surfe.be - passive income

SMTP server doesn't work to send email in laravel

Gmail SMTP server for sending email in Laravel

Are you looking for using Gmail SMTP server for sending email in Laravel? Sometimes SMTP server does not work deu to some server settings or configurations problem. To solve this problem now i am going to show you how to send email via SMTP server in laravel. One more benefit of using SMTP server is , you can send email from your local server also. By this way it will helpful for us to test email functionality on local server itself.

Setup of gmail SMTP server

It is better to know that laravel use Config/mail.php file to store details related to sending emails. This file contains settings like MAIL_SERVER , MAIL_HOST, MAIL_POST etc. For sending email . But we don’t need to setup or anything change in Config/mail.php file. You can change but it is not necessary to do that. So for doing that just open your .env file which is located in your root directory and follow given instructions – 

Default file code will loke like this

smtp server setup
MAIL_DRIVER = smtp
MAIL_HOST = smtp.mailtrap.io
MAIL_PORT = 465
MAIL_USERNAME =
MAIL_PASSWORD =
MAIL_ENCRYPTION = tls

Now change it which i have done below

setup gmail smtp server in laravel
MAIL_DRIVER = smtp
MAIL_HOST = smtp.googleemail.com
MAIL_PORT = 465
MAIL_USERNAME = your email address
MAIL_PASSWORD = your password
MAIL_ENCRYPTION = ssl

and finally save this file. Just Point to note that sometime  ”  MAIL_DRIVER = smtp " does not work so if you have trouble like that then just replace smtp by sendmail and  save this file. Last do just one thing. you need to make some changes in your Gmail settings. Login to your Google account . Then you will get some option which are look like and then click on Sign-in & Security 

setup gmail smtp server

After clicking sign in & security you have to scroll your mouse and go to the bottom of this page you will get a option Allow less secure apps and just do it like below image

That’s it! hope it will work for you. if works then inform us in comment box and if you have any trouble then also share with me your error  in comment box

Leave a comments

LET'S SOCIALITE

Recent Tweets

RECOMMENDED POST