MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to setup your Gmail account to send emails in Laravel

In my previous blog, I described how can you send an email with an attachment without saving it in the database you can read that here.

Now let’s continue with this topic. If you are laravel lover then definitely somehow it comes in your mind that how I can send an email through my own Gmail account … Here is the solution for it

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.

Step 1: Configure Gmail SMTP Server in Laravel Application

Laravel uses 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 .env file.

Thus, open your .envfile which is located in your root directory of our application and checkout for this settings:

default .env mail setup
default env mail setup

Now edit the details above as follows.

  • MAIL_DRIVER= smtp
  • MAIL_HOST= smtp.googlemail.com
  • MAIL_PORT= 465
  • MAIL_USERNAME=your Gmail username
  • MAIL_PASSWORD=your Gmail password
  • MAIL_ENCRYPTION= ssl

Step 2: Configure your Google Account

Login to your Google Email Account and click on Google Account Button. This button is displayed when you click on the profile picture in your Gmail Dashboard as shown.

Once you are on My Account Page then click on Security and scroll down to the bottom and you will find ‘Less secure app access’ settings. Click on the radio button to set it ON.

Step 3: Send Emails from your Laravel Application

At this point, all the basic setup has been completed. We can now write some Laravel PHP codes to send an email.

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.

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

Our test mail template mail.blade.php should just contain a few test codes as shown below.

Hello <strong>{{ $name }}</strong>,
<p>{{body}}</p>Code language: HTML, XML (xml)

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

Barack Obama GIF with the caption I think we're done here

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals

Related Posts

PHP Code for Godaddy VPS Server SMTP Email Relay

This page shows how to send email from a GoDaddy VPS through GoDaddy's SMTP relay on port 25 with plain PHP sockets and no extra libraries. Below…

Read More

Email Authentication & Communication Infrastructure in Modern DevOps: The 2026 Definitive Guide

In the high-stakes world of modern DevOps, we spend our days (and sometimes our nights) obsessing over the “golden signals” of site reliability: latency, traffic, errors, and…

Read More

The 5 Most Popular Email APIs Among Developers In 2026

In the modern world, where everything is going digital, email is among the most important means of communication both in personal and business life. As a developer,…

Read More

Senior Exchange Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Senior Exchange Administrator is accountable for the reliability, security, performance, and lifecycle management of the organization’s Microsoft messaging platform, typically spanning Exchange Online (Microsoft 365), Exchange Server (on-premises), or a hybrid configuration. This role ensures email and calendaring services are highly available, compliant, and aligned to business needs while proactively reducing operational risk and improving user experience.

Read More

Principal Exchange Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Principal Exchange Administrator is the senior technical authority responsible for the reliability, security, lifecycle, and operational excellence of the enterprise messaging platform—typically Microsoft Exchange Online/Exchange Server in a hybrid Microsoft 365 environment. This role exists to ensure email and calendaring services remain highly available, performant, compliant, and aligned with enterprise security and governance requirements while enabling modern collaboration capabilities across the organization.

Read More

Lead Exchange Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Lead Exchange Administrator owns the reliability, security, and operational excellence of the organization’s messaging platform, typically Microsoft Exchange Online (Microsoft 365) and/or a hybrid Exchange deployment with on‑premises Exchange servers. This role ensures email and calendaring services remain highly available, performant, compliant, and resilient, while continuously improving automation, monitoring, and service management maturity.

Read More