PHP code example of awsm3 / mandrill-zend3

1. Go to this page and download the library: Download awsm3/mandrill-zend3 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

awsm3 / mandrill-zend3 example snippets


/** @uses */
use Mandrill\Mandrill;
use Mandrill\Struct\Message;
use Mandrill\Struct\Recipient;
 
// instantiate a client object
$mandrill = new Mandrill('your_api_key');
 
// instantiate a Message object
$message = new Message();
 
// define message properties
$message->text = 'Hello, *|NAME|*!';
$message->subject = 'Test';
$message->from_email = '[email protected]';
$message->from_name = 'Mandrill API Test';
 
// instantiate a Recipient object and add details
$recipient = new Recipient();
$recipient->email = '[email protected]';
$recipient->name = 'Recipient Name';
$recipient->addMergeVar('NAME', $recipient->name);
 
// add the recipient to the message
$message->addRecipient($recipient);
 
// send the message
$response = $mandrill->messages()->send($message);

/** @uses */
use Mandrill\Mandrill;
use Mandrill\Struct\Message;
 
// convert from ZF message
// $zfMessage is instance of \Zend\Mail\Message
$message = Message::convertZFMail($zfMessage);
 
// add any field you want
$message->metadata = ...;
 
// instantiate a client object
$mandrill = new Mandrill('your_api_key');
 
// send the message
$response = $mandrill->messages()->send($message);