PHP code example of theroadbunch / mandrill-sdk
1. Go to this page and download the library: Download theroadbunch/mandrill-sdk 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/ */
theroadbunch / mandrill-sdk example snippets
// optional alias for cleanliness/readability
use RoadBunch\Mandrill as SDK;
// create a dispatcher factory
$factory = new SDK\DispatcherFactory('your_mandrill_api_key');
// create the dispatcher for the type of API call you'd like to make
$dispatcher = $factory->createMessageDispatcher();
// create an email message
$message = new SDK\Message\Message();
// build the email
$message->setSubject('An email subject');
$message->setText('The text body of the email');
$message->setHtml('The HTML email body');
// set recipients
$message->addTo('[email protected]', 'Recipient Name');
$message->addCc('[email protected]', 'CC Recipient Name');
// set senders
$message->setFrom('[email protected]', 'Admin');
$message->setReplyTo('[email protected]');
/** @var SDK\Message\SendResponse[] $response */
$response = $dispatcher->send($message);
array:2 [
0 => RoadBunch\Mandrill\Message\SendResponse {#22
+id: "118a7d900f5c48ec9a91cf55c63a7d97"
+email: "[email protected]"
+status: "sent"
+rejectReason: null
}
1 => RoadBunch\Mandrill\Message\SendResponse {#23
+id: "e19fb3f794ab4b99bd2a6a8ce4396a3f"
+email: "[email protected]"
+status: "sent"
+rejectReason: null
}
]