Send mail from laravel PHP framework and configure SMTP

Lots of web server do not allow to directly send email from website .They require SMTP authentication for security purpose.
Below we have created a laravel tutorial for Sending email and configuring SMTP in web server .


Step 1 : Create email

To use SMTP , we need to first create email id of our domain name ex: .
So, to do this open your website cpanel ex: /
Now access link ‘Email Account’ . There mention your email id ,password then click ‘Create Account’ .

Step 2 : Copy SMTP details

Here we have to copy SMTP details i.e

SMTP username
SMTP password
SMTP port 

These configuration can find from the same page that we created email .

  • Scroll to bottom of the page . Find your email , on right side click on ‘Set Up Mail Client’
  • Now on newly opened page , scroll quite middle of the page ,find there ‘Mail Client Manual Settings’
  • Find SMTP details on ‘ Secure SSL/TLS Settings ‘ or ‘Non-SSL Settings’ panel

If your website is not using https , you have to use ‘Non-SSL Settings’ .
Here note :

  • SMTP username is your email id
  • SMTP password is your email’s password that we created on 1st step
  • SMTP host is mentioned on ”Outgoing Server:’ ex:
  • SMTP port is mentioned on ‘Outgoing Server:’ ex: 25

Step 3: Put SMTP details on laravel’s config/mail.php

  • Put mail driver SMTP ex : driver ‘driver’ => env(‘MAIL_DRIVER’, ‘smtp’)
  • Put SMTP host ex: ‘host’ => env(‘MAIL_HOST’, ‘’)
  • Put SMTP port ex : ‘port’ => env(‘MAIL_PORT’,25)
  • Put SMTP username ex : ‘username’ => env(‘’)
  • Put SMTP password ex: ‘password’ => env(‘contact@abc’)

Now you will be able to send email from your Laravel application . To send mail , find below example code

Mail::send('',$data, function ($message) {
			$message->from('','Company Name');
			$message->to(' ');
			$message->subject('Contact form submitted on ');

  • Then King

    Hi bro,

    What is the host for SSL settings.