Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rad Mailer Laravel Package

devster/rad-mailer

View on GitHub
Deep Wiki
Context7

RAD Mailer

Build Status Scrutinizer Code Quality Code Coverage PHP version

Send Twig templated email with Swiftmailer at speed of light. Dead simple.

Installation

Composer

Add this to your composer.json

{
    "require": {
        "devster/rad-mailer": "~1.0"
    }
}

Usage

Global usage


// twig is optional, like from
$mailer = new Rad\Mailer($swiftmailer, $twig, $from = '[email protected]');

// Send a simple email
$nbEmailsSent = $mailer->send(array(
    // Optional. By default the value set in the constructor.
    // '[email protected]', array('[email protected]' => 'Bob', ...)
    // or an object (see more details below)
    'from'      => '[email protected]',
    // Same as from
    'to'        => '[email protected]',
    // A twig template as string or a twig file template (ex: email.html.twig)
    'subject'   => 'Hello {{name}}!',
    // Same as subject
    'body'      => 'body.html.twig',
    // Optional. The data used in both templates subject and body
    'data'      => array('name' => 'Rob'),
    // Optional, default: text/html. 'text/html' or 'text/plain'
    'body_type' => 'text/plain'
));

// Send a more complex email
// Create a \Swift_Message pre set with data
$message = $mailer->createMessage(array(
    'to'        => '[email protected]',
    'subject'   => 'Hello {{name}}!',
    'body'      => 'body.html.twig',
    'data'      => array('name' => 'Rob'),
));

$message->attach(\Swift_Attachment::fromPath('/path/to/image.jpg'));

$nbEmailsSent = $mailer->sendMessage($message);

This library is aims to work with symfony, so you can pass an object as from and to option. This object must has:

* an `email` public property
* or `mail` public property
* or a `getEmail` public method
* or a `getMail` public method
* and a `name` public property
* or a `getName` public method
* or a `__toString` public method

Or you can extends the getDataFromObject method from the Rad\Mailer.

Symfony

Register the mailer as service

services:
    rad_mailer:
        class: Rad\Mailer
        arguments: [@mailer, @twig, '[email protected]']

Why not a bundle? Because its overkill. period.

Silex

$app = new \Silex\Application;

$app->register(new \Silex\Provider\SwiftmailerServiceProvider, ...);
$app->register(new \Silex\Provider\TwigServiceProvider, ...);

$app->register(new \Rad\Silex\MailerServiceProvider, array(
    'rad_mailer.from'  => '[email protected]', // Optional
    'rad_mailer.class' => 'MyMailer\That\Extends\Rad\Mailer', // Optional. By default 'Rad\Mailer' of course
));

$app['rad_mailer']->send(array(...));

License

This plugin is licensed under the DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator