ride / lib-mail-mandrill
Mandrill implementation for the mail library of the Ride framework
Installs: 3 837
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 0
Open Issues: 0
Requires
- mailchimp/transactional: ^1.0
- ride/lib-log: ^1.0.0
- ride/lib-mail: ^1.0.0
README
Mandrill implementation for the mail library of the PHP Ride framework.
For more information, you can check the Mandrill website.
What's In This Library
MandrillTransport
The MandrillTransport class implements the Transport interface. It uses the Mandrill rest API to send mails. You can set tags and the subaccount for all mails sent by the transport.
MandrillMailMessage
The MandrillMessage class extends the MailMessage class. You can set tags and the subaccount for a mail message individually.
Code Sample
<?php use ride\library\log\Log; use ride\library\mail\transport\MandrillTransport; function createTransport($apiKey, Log $log) { $transport = new MandrillTransport($apiKey, $log); // a tag and subaccount to be set on all mails which don't set tags or a subaccount $transport->addTag('newsletter'); $transport->setSubAccount('my-subaccount'); return $transport; } function sendMail(MandrillTransport $transport) { // like any mail message $message = $transport->createMessage(); $message->setSubject('My subject'); $message->setRecipient('to@domain.com'); $message->addCc('To 2 <to2@domain.com>'); $message->addBcc(array('to3@domain.com', 'To 3 <to3@domain.com>')); $message->setIsHtmlMessage(true); $message->setMessage('<html><body><p>...</p></body></html>'); // mandrill extension, override the transport tags and subaccount $message->addTag('registration'); $message->setSubAccount('my-other-subaccount'); // send it try { $transport->send($message); } catch (MailException $exception) { } }
Related Modules
Installation
You can use Composer to install this library.
composer require ride/lib-mail-mandrill