Skip to content

Latest commit

 

History

History
106 lines (77 loc) · 2.45 KB

README.md

File metadata and controls

106 lines (77 loc) · 2.45 KB

Mailblade

Mailblade is a Laravel plugin that lets you manage your email templates in Laravel easily and without hassle. You can use the powerful Blade templating engine inside your emails for your html templates.
IMPORTANT: For the text version of the templates we stick with regular php.

Install it

Via Laravel's very own artisan tool:

php artisan bundle:install mailblade

Activate it

Go into you application/bundles.php file and add this line to your bundles array:

'mailblade' => array('auto' => true)

Usage

Mailblade is usable out of the box.
You handle it as you handle any view in Laravel:

$message = Mailblade::make('password-restore');
$message->with('email', '[email protected]')
$message->with('key', 'Fhgns7396&-21dj');

Or even like this:

$input = array(
  'email' => '[email protected]',
  'key'   => 'Fhgns7396&-21dj'
);

$message = Mailblade::make('password-restore', $input);

To see the html version of a template simply do:

$html = Mailblade->html();

For the text version:

$txt = Mailblade->text();

Configuration

Mailblade views are different to your 'regular' Laravel Views in two ways:

  1. You choose the default folder for your templates.
  2. They are language-aware

Let us explain...

1. The template directory

By default, Mailblade chooses your email template from the mailblade/viewsfolder.
You can choose any folder you want for your template files by going into mailblade/config/options.php file.

2. Language-aware

Mailblade chooses the appropriate template based on your application language.
Make sure you follow this convention when placing your files:

[template_dir]/[language]/[template_name].blade.php

So, for example, the english version of the 'contact-message' template sould be placed like this:

mailblade/templates/en/contact-message

Give me some templates

The best thing about Mailblade is that it comes with templates for sending commonly used email messages, like:

  • Contact form
  • Password restore
  • User confirmations

You can even preview the messages if you do something like this in your routes files:

Route::get('preview', function()
{
  return Mailblade::make('your-template')->html();
}

Or for the text version

Route::get('preview', function()
{
  return Mailblade::make('your-template')->text();
}

Note: (Templates are on the way and will be pushed soon)