コード例 #1
0
ファイル: Messages.php プロジェクト: jlinn/mandrill-api-php
 /**
  * Send a new transactional message through Mandrill using a template
  * @param string $templateName the immutable name or slug of a template that exists in the user's account
  * @param Message $message
  * @param array $templateContent array(array('name' => 'example_name', 'content' => 'example_content'))
  * @param bool $async set to true to enable asynchronous sending
  * @param string $ipPool optional name of the ip pool which should be used to send the message
  * @param string $sendAt optional UTC timestamp (YYY-MM-DD HH:MM:SS) at which the message should be sent
  * @return array
  * @link https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template
  */
 public function sendTemplate($templateName, Message $message, array $templateContent = array(), $async = false, $ipPool = NULL, $sendAt = NULL)
 {
     if (!sizeof($templateContent)) {
         $templateContent = array('');
         // Mandrill will not accept an empty array for template_content, but it does not require any actual content.
     }
     return $this->request('send-template', array('template_name' => $templateName, 'template_content' => $templateContent, 'message' => $message->toArray(), 'async' => $async, 'ip_pool' => $ipPool, 'send_at' => $sendAt));
 }
コード例 #2
0
 public function testSend()
 {
     $this->getServer()->enqueue($this->getMockResponse('send')->getMessage());
     $recipient = new Recipient();
     $recipient->email = '*****@*****.**';
     $recipient->name = 'Recipient Name';
     $recipient->addMergeVar('NAME', $recipient->name);
     $message = new Message();
     $message->addRecipient($recipient);
     $message->text = 'Hello, *|NAME|*!';
     $message->subject = 'Test';
     $message->from_email = '*****@*****.**';
     $message->from_name = 'Mandrill API Test';
     $response = $this->messages->send($message);
     $this->assertGreaterThan(0, sizeof($response));
     $this->assertEquals('sent', $response[0]['status']);
 }