Laravel provides many methods to send emails. You may use a plain PHP method to send emails, or you may use some email service providers such as Sendinblue, Mailgun, Sendgrid, Mandrill, Amazon SES, etc.

To send emails on a production server, simply edit the mail.php configuration file, which is placed in the config directory.

Here is the file without comments:

return [

    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', ''),

    'port' => env('MAIL_PORT', 587),

    'from' => ['address' => null, 'name' => null],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

    'sendmail' => '/usr/sbin/sendmail -bs',

    'pretend' => false,

To send emails on a local development server (Homestead), simply edit the .env file.


As usual, you may learn how to use Mailgun, Mandrill and SES drivers at the official docs:

Because we're working on Homestead, we will learn how to send emails on Homestead using Gmail and Sendinblue for FREE!!!!!

Sending emails using Gmail

If you have a gmail account, it's very easy to send emails using Laravel 5!

First, go to:

Take a look at the Sign-in & security -> Connected apps & sites -> Allow less secure apps settings.

You must turn the option "Allow less secure apps" ON.

Configure Gmail

Once complete, edit the .env file:


Well done! You're now ready to send emails using Gmail!

If you get this error when sending email: "Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators"

You may try one of these methods:

  • Go to, click continue and unlock your account for access through other media/sites.

  • Using a double quote password: "your password"

  • Try to use only your Gmail username: yourGmailUsername

Sending emails using Sendinblue

SendGrid isn't free any more, so we'll use Sendinblue instead.

Go to Sendinblue, register a new account:

When your account is activated, edit the .env file:


Good job! You're now ready to send emails using Sendinblue!

Sending a test email

To send a test email, open routes.php file and add this route:

Route::get('sendemail', function () {

    $data = array(
        'name' => "Learning Laravel",

    Mail::send('emails.welcome', $data, function ($message) {

        $message->from('[email protected]', 'Learning Laravel');

        $message->to('[email protected]')->subject('Learning Laravel test email');


    return "Your email has been sent successfully";


As you see, we use the send method on the Mail facade. There are three arguments:

  1. The name of the view that we use to send emails.

  2. An array of data that we want to pass to the email.

  3. A closure that we can use to customize our email subjects, sender, recipients, etc.

When you visit, Laravel will try to send an email. If the email is sent successfully, Laravel will display a message.

Note: Be sure to replace [email protected] with your real email address

Finally, we don't have the welcome.blade.php view yet, let's create it and put it in the emails directory.

<!DOCTYPE html>
<html lang="en-US">
    <meta charset="utf-8">
<h2>Learning Laravel!</h2>

    Welcome to {!! $name !!} website!


Because we've passed an array containing the $name key in the above route, we could display the name within this welcome view using:

{!! $name !!}


<?php echo $name ?>

Done! Now go to, you should see:

Sent email successfully

Check your inbox, you should receive a new email!

Feel free to customize your email address, recipients, subjects, etc.

Note: This is a Chapter 3's section of Learning Laravel 5 book. You can read the book for free here: