Download the PHP package nordsoftware/lumen-mandrill-mailer without Composer
On this page you can find all versions of the php package nordsoftware/lumen-mandrill-mailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nordsoftware/lumen-mandrill-mailer
More information about nordsoftware/lumen-mandrill-mailer
Files in nordsoftware/lumen-mandrill-mailer
Package lumen-mandrill-mailer
Short Description Mandrill mailer for the Lumen PHP framework.
License MIT
Informations about the package lumen-mandrill-mailer
lumen-mandrill-mailer
Mandrill mailer for the Lumen PHP framework.
Send email messages via the Mandrill API, either with a template, or plain emails.
Install
// .env:
MANDRILL_API_KEY=<ANY_VALID_API_KEY>
MANDRILL_PRETEND=<TRUE|FALSE>
// config/mandrillmailer.php
return [
'secret' => env('MANDRILL_API_KEY'),
'pretend' => env('MANDRILL_PRETEND', false),
];
// bootstrap/app.php
...
$app->configure('mandrillmailer');
...
$app->register(Nord\Lumen\Mandrill\Mailer\MandrillMailServiceProvider::class);
Usage
You can add support for sending Mandrill emails to any part of your application. Use the SendsEmails
trait to do so:
...
use \Nord\Lumen\Mandrill\Mailer\App\SendsEmails;
...
Then later on in your code, you may use the functions $this->sendRaw(MandrillMailMessage $message)
to send raw message,
or $this->sendTemplate(MandrillMailMessage $message)
to send a template email. You will need to construct the message to
be sent:
...
$message = new \Nord\Lumen\Mandrill\Mailer\Infrastructure\MandrillMailMessage(
['Recipient Name' => '[email protected]'], // To address.
['From Name' => '[email protected]'], // From address.
'Email Subject', // Subject.
[ // Message body.
'html' => '<h1>Message body HTML</h1>',
'text' => 'Message body plain text',
'data' => [
'templateVariableName' => 'TemplateVariableValue',
'firstName' => 'First Name',
'lastName' => 'Last Name',
...
],
],
'template-name', // Mandrill template name. Optional.
[
'templateContent' // Template content. Optional.
],
'[email protected]', // CC Address. Optional.
'[email protected]', // BCC Address. Optional.
[ // Attachments. Optional.
[
'type' => 'image/png', // Required field.
'name' => 'attachment1.png', // Required field.
'content' => base64_encode(file_get_contents(/full/path/to/attachment1.png)), // Required field.
],
[
'type' => 'image/png',
'name' => 'attachment2.png',
'content' => base64_encode(file_get_contents(/full/path/to/attachment2.png)),
],
],
[ // Headers. Optional
'Reply-To' => '[email protected]',
],
[ // Images. Optional.
[
'type' => 'image/png', // Required field.
'name' => 'image1.png', // Required field.
'content' => base64_encode(file_get_contents(/full/path/to/image1.png)), // Required field.
],
],
);
...
License
See LICENSE.