How to send an Email in Laravel7 using Gmail SMTP Server

Tilak poudel
3 min readJul 18, 2020

If you are in trouble thinking how to send email in Laravel 7 using google SMTP, then you are going to figure it out using default SMTP settings using PHP default mail() function.

Let’s Get started

Step 1: Configure your gmail Account

Login into your gmail account.

Goto to Manage account :

After entering into , click on to the security tab and turn on Less secure app access

Now you are ready to configure in the laravel code .

Step 2 : Configure gmail SMTP Server in laravel App.

To add the required information, we need not edit the config/mail.php file, rather we would supply these details accordingly in the .env file.

Now open the env file and edit as below :

Now we are ready to code to send email as per our requirement.

Step 3 : Send Email from laravel app

To get started, create any controller of choice where the mail sending logic will be handled, then in this controller write your codes using the code snippet below as a guide.

Here change the sender address , recepient address , and your message you want to send under body ,include appropriate subject .

In the above code, we are using our mail template as ’coustom_emails.mail’ file . hence we need to create an ‘coustom_emails’ folder and the mail.blade.php file at resources\views\coustoms_emails\mail.blade.php.

Our test mail template mail.blade.php should just contains a few test codes as shown below. you can decorate as you want .:)

Hurray, we are done, simply create any route of your choice to and start sending mails from your Laravel application.

I hope this instruction is helpful . Don’t forget to leave your comments below, if you have any. Happy coding :)

--

--