public function Mandrill_MessagesTest::sendTemplate in Mandrill 7.2
See also
Mandrill_Messages::sendTemplate()
File
- tests/
includes/ mandrill_messages_test.inc, line 46 - A virtual Mandrill Messages API implementation for use in testing.
Class
- Mandrill_MessagesTest
- @file A virtual Mandrill Messages API implementation for use in testing.
Code
public function sendTemplate($template_name, $template_content, $message, $async = FALSE, $ip_pool = NULL, $send_at = NULL) {
if (!isset($message['to']) || empty($message['to'])) {
return $this->master
->getErrorResponse(12, 'ValidationError', 'No recipients defined.');
}
$response = array();
$templates = mandrill_get_templates();
$matched_template = NULL;
foreach ($templates as $template) {
if ($template['name'] == $template_name) {
$matched_template = $template;
continue;
}
}
if ($matched_template == NULL) {
return $this->master
->getErrorResponse(12, 'Unknown_Template', 'No template with name: ' . $template_name);
}
$recipients = mandrill_get_to($message['to']);
foreach ($recipients as $recipient) {
$recipient_response = array(
'email' => $recipient['email'],
'status' => 'sent',
'reject_reason' => '',
'_id' => uniqid(),
);
$response[] = $recipient_response;
}
return $response;
}