Notice: We've changed the service to Sendgrid.

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 Sendgrid, Mandrill, Amazon SES, etc.

send emails in laravel

Note: if you're not using Laravel, you can still use Sendgrid to send up to 9300 emails/month for free!

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' => env('MAIL_FROM_ADDRESS', '[email protected]'),
    'name' => env('MAIL_FROM_NAME', 'Example'),

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

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

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

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

    'markdown' => [
    'theme' => 'default',

    'paths' => [

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 working on Homestead, we will learn how to send emails on Homestead using Sendgrid for FREE!!!!!

Sending emails using Sendgrid

Go to Sendgrid, register a new account (free):

Sendgrid website - You can click here to register and learn more about Sendgrid

send emails with laravel

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


Note: If you're sending emails on a production server, be sure to edit the mail.php file

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

Sending a test email

To send a test email, open web.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 http://homestead.test/sendemail, you should see:

Note: Replace homestead.test with your app address if the address is different.

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: