How to send beautiful HTML emails with Laravel using Beauty mail

How to send beautiful HTML emails with Laravel using Beauty mail

Hello everyone, welcome back to just laravel. Here am going to show you how you can send clean and beautiful HTML emails in your laravel applications using this Beauty mail package by SnowFire. In one of my previous post I showed you how to send emails using SendGrid mail service provider, here I extended to send a clean and elegant HTML emails rather than plain text emails.

Working Demo      Project on Github

Setting up Beautymail

So first pull this package into our application.

composer require snowfire/beautymail dev-master

After composer finishes its installation, you need to add it to the service providers list in \config\app.php

'providers' => [

Now you need to publish some of the assets provided by this package to the public folder,

php artisan vendor:publish --provider="Snowfire\Beautymail\BeautymailServiceProvider"

Beautymail allows us to set some configurations for sending emails, where you can set logo to be sent in the email, its dimensions, and any social  links to be included in you mail and all such settings.

Working Demo      Project on Github

You can change you settings in \config\beautymail.php.


return [

    'colors' => [

        'highlight' => '#004ca3',
        'button'    => '#004cad',


    'view' => [
        'senderName'  => null,
        'reminder'    => null,
        'unsubscribe' => null,
        'address'     => null,

        'logo'        => [
            'path'   => '%PUBLIC%/img/logo.png',
            'width'  => '100',
            'height' => '100',

        'twitter'  => 'justLaravel',
        'facebook' => 'justLaravel',


View for entering email

I have made a simple app to show how this works, I place a input box, where one can enter an email address. Then that email address will be validate an will send a mail to that email address with our html email template we designed and customized.

So our view will look like,

HTML emails using Beautymail in laravel -
HTML emails using Beautymail in laravel –

It is basically a form with a single input for email adddress and a submit button for sending an email.

<form action="{{ URL::to('/sendMail') }}" method="POST">
    {{ csrf_field() }}
    <div>Email: <input class="input_email"  type="email" name="email" required></div>
    <button class="sendmailBtn" type="submit">Send Email</button>

So when the submit button is pressed it goes to the route sendmail where you can send an email, but before that I will design the view for the email to be sent.

Working Demo      Project on Github

Designing and customizing your email view

Beautymail provides us with few email templates to use, I use of them here and add some custom content to the view it provided. To see all the available templates, you can visit their GitHub repo:

I used ‘ark’ template, here is the example code they provided,



    @include('beautymail::templates.ark.heading', [
        'heading' => 'Hello World!',
        'level' => 'h1'


        <h4 class="secondary"><strong>Hello World</strong></h4>
        <p>This is a test</p>


    @include('beautymail::templates.ark.heading', [
        'heading' => 'Another headline',
        'level' => 'h2'


        <h4 class="secondary"><strong>Hello World again</strong></h4>
        <p>This is another test</p>



Here I removed the default hello world content and added some of post links and images and some text. You can add any content you want in between @include('beautymail::templates.ark.contentStart') and @include('beautymail::templates.ark.contentEnd')

Sending the mail

Firstly, to sen a mail you need to do some settings like setting up mailhost, username password and all. I used sengrid to send mail here. I also have a post covering how to get registered at send grid and send mails using it. Please look at that here.

Recommended: How to use SendGrid email service provider to send emails using laravel

In the form I set the action to \sendMail, so I made a route for it,

Route::post('/sendMail', 'IndexController@sendMail');

In IndexController, I had a new function sendMail

public function sendMail(Request $request){
    $this->validate($request, [
        'email' => 'bail|required|email',
    $beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class);
    $beautymail->send('emails.welcome', [], function($message) 
        $email = Input::get('email');
            ->to($email, 'Howdy buddy!')
            ->subject('Test Mail!');
         return Redirect::back();
    //return view('welcome');

In the above code, the following 2 lines sends a mail,

$beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class);
$beautymail->send('emails.welcome', [], function($message) 

In the function message, you can add from address to address and subject for the mail.

After sending mail you can return to any success view or anything you wish, Here for the example sake, am just redirecting back.

I also added some validation for the email input, if you look at the initial lines of the function, I check the email for required and for a valid email case.

You can show the errors in the view, where ever you want by placing the following code,

@if ($errors->any())
    @foreach ($errors->all() as $error)
        <div style="color:red; font-size:18px !important;"> {{ $error }}</div>

The sent mail will look like the following,

HTML mail using Beautymail in laravel -
HTML emails using Beautymail in laravel –

Also my custom content I inserted will look like,

HTML mail using Beautymail in laravel -
HTML emails using Beautymail in laravel –

Also facebook and twitter icons in the footer,

HTML mail using Beautymail in laravel -
HTML emails using Beautymail in laravel –

That’s it for the post. Now you successfully know how to send beautiful emails from your laravel applications.

Working Demo      Project on Github

Please feel free to look at some of my previous post below,

[display-posts posts_per_page=”5″ order=”DESC”]


4 thoughts on “How to send beautiful HTML emails with Laravel using Beauty mail”

  • 1
    PHPSCOTS on August 28, 2017 Reply

    Hey Nice Article! Keep Writing, Do you know we are taking guest posts on Laravel articles you can post your articles here too

  • 2
    bhavana on February 26, 2020 Reply

    Class ‘Illuminate\Support\Facades\Input’ not found

    • 3
      avinash on February 26, 2020 Reply

      Did you try importing `use Illuminate\Support\Facades\Input;`

  • 4
    Maksud on October 3, 2020 Reply

    how to pass variable into views using BeautyMail?

Leave a Reply