rareloop/lumberjack-email

There is no license information available for the latest version (v1.2.0) of this package.

v1.2.0 2020-02-28 16:34 UTC

This package is auto-updated.

Last update: 2020-08-31 00:45:47 UTC


README

This package provides a simple way to send rich emails using Twig templates. A small wrapper around wp_mail();

Once installed, register the Service Provider in config/app.php:

'providers' => [
    ...

    Rareloop\Lumberjack\Email\EmailServiceProvider::class,

    ...
],

Sending Emails

You then have access to the Rareloop\Lumberjack\Email\Facades\Email facade and can create emails:

Send an HTML email

use Rareloop\Lumberjack\Email\Facades\Email;

Email::sendHTML(
    'recipient@mail.com',
    'Email Subject line',
    '<p>Email body goes here</p>'
);

// Or with a reply-to email
Email::sendHTML(
    'recipient@mail.com',
    'Email Subject line',
    '<p>Email body goes here</p>',
    'reply-to@mail.com'
);

Send an HTML email using a Twig template

The twig file will be compiled using Timber before sending.

use Rareloop\Lumberjack\Email\Facades\Email;

Email::sendHTMLFromTemplate(
    'recipient@mail.com',
    'Email Subject line',
    'email.twig',
    [ 'name' => 'Jane Doe' ] // Twig context
);

Send a plain text email

use Rareloop\Lumberjack\Email\Facades\Email;

Email::sendPlain(
    'recipient@mail.com',
    'Email Subject line',
    'Plain text body',
);

Config

You can also specify an SMTP server to use for emails by creating a config/email.php file:

return [
    'smtp' => [
        'hostname' => '',
        'username' => '',
        'password' => '',
        'auth' => true|false,
        'port' => '',
    ],
];