SMTP Server Doesn't Work To Send 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.

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 –

 

Read also Gmail configuration setup to send mail in Laravel

 

Default file code will loke like this

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

.env

MAIL_DRIVER = smtp
MAIL_HOST = smtp.googleemail.com
MAIL_PORT = 465
MAIL_USERNAME = your email address
MAIL_PASSWORD = your password
MAIL_ENCRYPTION = ssl

 

Hope now your mail will be send from your laravel app. If you still face error then visit here 

 

Login to Google - Sign in - Google Accounts

 

and then after visiting this link you will find security option. Then click on it and scorll down from top to bottom.

smtp-server-does-not-work-for-send-email-in-laravel

Now just make it sure that your Less secure app access is on.

gmail-configuration-setup-for-laravel

 

Now hope it will work for you. Hope it can help you.

 

#laravel #smtp-server-error #error #gmail-configuration #gmail-configuration-setup #laravel-mail #googleemail #sendemail