Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snowfire/Beautymail
Send beautiful HTML emails with Laravel
https://github.com/snowfire/Beautymail
beautiful-html-emails email laravel
Last synced: 8 days ago
JSON representation
Send beautiful HTML emails with Laravel
- Host: GitHub
- URL: https://github.com/snowfire/Beautymail
- Owner: snowfire
- Created: 2014-07-27T19:31:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-20T13:32:25.000Z (23 days ago)
- Last Synced: 2024-10-29T15:33:18.088Z (14 days ago)
- Topics: beautiful-html-emails, email, laravel
- Language: Blade
- Size: 220 KB
- Stars: 1,230
- Watchers: 32
- Forks: 207
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Beautymail for Laravel
Beautymail makes it super easy to send beautiful responsive HTML emails. It's made for things like:
* Welcome emails
* Password reminders
* Invoices
* Data exports### Index:
- [Templates](#templates)
- [Installation](#installation)
- [Send your first Beauty mail](#send-your-first-beauty-mail)
- [Options](#options)
- [Lumen support](#lumen-support)## Templates
There are tons of great looking HTML email templates out there. Campaign Monitor and Mailchimp has released hundreds for free. It is pretty simple to adapt a template to Beautymail.
__Widgets__ by [Campaign Monitor](https://www.campaignmonitor.com/templates/all/):
![Widget Template](screenshots/widgets.png?raw=true "Widgets template")
__Minty__ by __Stamplia__:
![Widget Template](screenshots/minty.png?raw=true "Widgets template")
__Sunny__
![Widget Template](screenshots/sunny.png?raw=true "Sunny template")
## Installation
Add the package to your `composer.json` by running:
```bash
composer require snowfire/beautymail
```
Configure your settings such as logo url and social links in `config/beautymail.php`## Send your first Beauty mail
Add this to your `routes/web.php`
```php
Route::get('/test', function()
{
$beautymail = app()->make(Snowfire\Beautymail\Beautymail::class);
$beautymail->send('emails.welcome', [], function($message)
{
$message
->from('[email protected]')
->to('[email protected]', 'John Smith')
->subject('Welcome!');
});});
```Now create `resources/views/emails/welcome.blade.php`
```html
@extends('beautymail::templates.widgets')@section('content')
@include('beautymail::templates.widgets.articleStart')
Hello World
This is a test
@include('beautymail::templates.widgets.articleEnd')
@include('beautymail::templates.widgets.newfeatureStart')
Hello World again
This is another test
@include('beautymail::templates.widgets.newfeatureEnd')
@stop
```That's it!
## Options
### _Template:_ Widgets
To change colours for the different segments, pass a colour variable:
```php
@include('beautymail::templates.widgets.articleStart', ['color' => '#0000FF'])
```#### Minty template example
```html
@extends('beautymail::templates.minty')@section('content')
@include('beautymail::templates.minty.contentStart')
Welcome Steve
This is a paragraph text
This is a heading
More paragraph text.
@include('beautymail::templates.minty.button', ['text' => 'Sign in', 'link' => '#'])
@include('beautymail::templates.minty.contentEnd')@stop
```### Ark template example
```html
@extends('beautymail::templates.ark')@section('content')
@include('beautymail::templates.ark.heading', [
'heading' => 'Hello World!',
'level' => 'h1'
])@include('beautymail::templates.ark.contentStart')
Hello World
This is a test
@include('beautymail::templates.ark.contentEnd')
@include('beautymail::templates.ark.heading', [
'heading' => 'Another headline',
'level' => 'h2'
])@include('beautymail::templates.ark.contentStart')
Hello World again
This is another test
@include('beautymail::templates.ark.contentEnd')
@stop
```#### Sunny template example
```html
@extends('beautymail::templates.sunny')@section('content')
@include ('beautymail::templates.sunny.heading' , [
'heading' => 'Hello!',
'level' => 'h1',
])@include('beautymail::templates.sunny.contentStart')
Today will be a great day!
@include('beautymail::templates.sunny.contentEnd')
@include('beautymail::templates.sunny.button', [
'title' => 'Click me',
'link' => 'http://google.com'
])@stop
```## Lumen support
In order to get this working on Lumen follow the installation instructions except for the `artisan vendor:publish` command, since Lumen does not provide this command. Instead you have to copy the assets folder from `vendor/snowfire/beautymail/public/` to the public folder in your Lumen project manually.
Make sure to also put the `beautymail.php` config file in the `config` folder (default available in `src/config/settings.php`)
### Enable mailing in Lumen
After this you will need to install and configure `illuminate/mailer` with:
composer require illuminate/mail
and add this to your `bootstrap/app.php`:$app->withFacades();
$app->register(App\Providers\AppServiceProvider::class);See [this blog post](https://medium.com/@edwardsteven/using-lumen-and-laravel-mail-with-mailgun-270415daed37) for more details and how to use different mail libraries in lumen:
### Configure Beautymail classes and configuration parameters
In order to get Beautymail working on Lumen you need to add the following to your `bootstrap/app.php` in order to resolve missing config files, parameters and classes (before you register `BeautymailServiceProvider`):
// Provide required path variables
$app->instance('path.config', env("STORAGE_DIR", app()->basePath()) . DIRECTORY_SEPARATOR . 'config');
$app->instance('path.public', env("STORAGE_DIR", app()->basePath()) . DIRECTORY_SEPARATOR . 'public');// Enable config for beautymail
$app->configure('beautymail');
// Provide class alliases to resolve Request and Config
class_alias(\Illuminate\Support\Facades\Request::class, "\Request");
class_alias(\Illuminate\Support\Facades\Config::class, "\Config");### Start using Beautymail
Congratulations, you can know start using Beautymail in Lumen. See: [Send your first Beauty mail](#send-your-first-beauty-mail) on what to do next.