How to Configure SMTP in Laravel

SMTP is a secure way to send emails. Laravel supports sending mail via SMTP out of the box. To configure your laravel app to send mail via SMTP, we need t provide the correct details for config/mail.php These details are however provided as environment variables on the .env file inside the apps root

Last updated 30 Nov 2026Also in: Email and Workplace

SMTP is a secure way to send emails. Laravel supports sending mail via SMTP out of the box.

To configure your laravel app to send mail via SMTP, we need t provide the correct details for config/mail.php These details are however provided as environment variables on the .env file inside the apps root directory

Once there, you will edit the fields below. If they are not there on your .env file, you can add them

MAIL_DRIVER= MAIL_HOST= MAIL_PORT= MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=

Using Truehost SMTP servers.

if your mails operate from our servers in shared hosting, use the details below

MAIL_DRIVER=smtp MAIL_HOST=ENTER_YOUR_SERVER_HOSTNAME MAIL_PORT=587 MAIL_USERNAME=ENTER_YOUR_FULL_EMAIL_ADDRESS MAIL_PASSWORD=ENTER_EMAIL_PASSWORD MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=ENTER_YOUR_FULL_EMAIL_ADDRESS MAIL_FROM_NAME="$APP_NAME"

Where:

MAIL_DRIVER=smtp tells the app to use SMTP method to send mails. There are other methods available

MAIL_HOST=ENTER_YOUR_SERVER_HOSTNAME is your server hostname e.g pld109.truehost.cloud. If unsure, you can check your cPanel welcome email for your hostname or contact support

MAIL_PORT=587 is the SMTP port. Should be 587 always

MAIL_USERNAME=ENTER_YOUR_FULL_EMAIL_ADDRESS is your full email address e.g [email protected]

MAIL_PASSWORD=ENTER_EMAIL_PASSWORD is your email password

MAIL_ENCRYPTION=tls is the encryption method to use, should always be tls if port is 587

MAIL_FROM_ADDRESS=ENTER_YOUR_FULL_EMAIL_ADDRESS must be the same as MAIL_USERNAME otherwise your mails will go to Spam

Using Gmail SMTP servers

If you want to use Gmail instead of your cPanel emails to send mails, the same variables as above will be used but the values changed as follows

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=ENTER_YOUR_GMAIL_EMAIL_ADDRESS MAIL_PASSWORD=ENTER_EMAIL_PASSWORD MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=ENTER_YOUR_GMAIL_EMAIL_ADDRESS MAIL_FROM_NAME="$APP_NAME"

As with the previous settings, the following need to be noted

MAIL_HOST changes to smtp.gmail.com instead of our serverโ€™s hostname

MAIL_USERNAME and MAIL_FROM_ADDRESS change to your Gmail address. Should be the same value.

For Gmail, an additional step is required.

Login to your Gmail address then click your Profile Photo and click Manage your Google Account. You will be redirected to a new page

On the new page, click Security on your left the scroll down and find Less Secure Apps. Click on Turn on Access (not recommended).

Was this article helpful?