Skip to content

all-ride/ride-lib-mail-mandrill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ride: Mail Library (Mandrill)

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages