Weave Code
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 = 'john@example.com');

// Send a simple email
$nbEmailsSent = $mailer->send(array(
    // Optional. By default the value set in the constructor.
    // 'bob@example.com', array('bob@example.com' => 'Bob', ...)
    // or an object (see more details below)
    'from'      => 'bob@example.com',
    // Same as from
    'to'        => 'robert@example.com',
    // 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'        => 'robert@example.com',
    '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, 'rob@example.com']

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'  => 'rob@example.com', // 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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity