Skip to content
Murat Bastas edited this page Aug 12, 2017 · 2 revisions

Welcome to the mail-template wiki!

At here, you can look at the templates, learn how to use and how to override blocks.

How to install mail-template?

Add the package is to your composer.json file with this command,

composer require muratbsts/mail-template dev-master

Add the service provider to your config/app.php configuration file,

<?php
return [
    ...
    'providers' => [
        ...
        Muratbsts\MailTemplate\Providers\MailTemplateServiceProvider::class,
        ...
     ],
     ...
];

Create a config file like config/mailtemplate.php

<?php
return [
    'template'  => 'default',
    'footnote'  => null,

    'logo'      => [
        'path'  => null,
        'link'  => null,
    ],

    'from'      => '[email protected]',
    'cc'        => null,
    'bcc'       => null,
];

You can look at the templates are here and you can change template value default with you liked template name.

You can set a logo and link. And you can override to these configurations in your custom template or in send method.

Usage

Use package as like below in your method

<?php

use Muratbsts\MailTemplate\MailTemplate as MailTemplate;

class XyzController extends Controller
{
    public function send()
    {
        $mailer = app()->make(MailTemplate::class);
    
        $mailer->send('emails.welcome', [
            'button' => [
                'text' => 'Sign up now!',
                'link' => 'https://google.com',
            ]
        ], function ($message) use ($user) {
            $message->to($user->email, $user->name)->subject('Welcome!');
        });
    }
}

The next step is making a view. We'll create an email view like emails/welcome.blade.php

Continue on the creating e mail views

Clone this wiki locally