In this tutorial, we will discuss how to configure our Laravel applications to send emails using your Gmail account as a Gmail SMTP server with the default Laravel SMTP configurations.
The benefits of using an SMTP server cannot be over-emphasized, with an SMTP server we can send emails from our local server. Thus, giving us the ability to test the email functionality on the local server itself. Mails sent via SMTP are not flagged as SPAM by Gmail as seen in emails sent using the PHP default
Open cPanel And Open your API code. and edit .env file
Configure Gmail SMTP Server in Laravel Application
config/mail.php file for storing details used in mail sending. This file contains settings like MAIL_DRIVER, MAIL_HOST, MAIL_PORT, etc. In order to successfully send an email, we need to provide this information.
To add this required information, we need not edit this
config/mail.php file, rather we would supply these details accordingly in the
Thus, open your
.env file which is located in your root directory of our application and checkout for these settings:
Now edit the details above as follows.
In the above settings, we configured MAIL_DRIVER as SMTP, MAIL_HOST for Gmail as smtp.googlemail.com, MAIL_ PORT for Gmail as 465, and MAIL_ENCRYPTION method as SSL.
The MAIL_USERNAME and PASSWORD should be replaced with your Gmail Email address and Password respectively.
Make sure you are not using GMAIL SMTP, because they have closed the smtp service
You are done!!