vendor/mandrill/mandrill/src/Mandrill/Messages.php line 4

Open in your IDE?
  1. <?php
  2. class Mandrill_Messages {
  3. public function __construct(Mandrill $master) {
  4. $this->master = $master;
  5. }
  6. /**
  7. * Send a new transactional message through Mandrill
  8. * @param struct $message the information on the message to send
  9. * - html string the full HTML content to be sent
  10. * - text string optional full text content to be sent
  11. * - subject string the message subject
  12. * - from_email string the sender email address.
  13. * - from_name string optional from name to be used
  14. * - to array an array of recipient information.
  15. * - to[] struct a single recipient's information.
  16. * - email string the email address of the recipient
  17. * - name string the optional display name to use for the recipient
  18. * - type string the header type to use for the recipient, defaults to "to" if not provided
  19. * - headers struct optional extra headers to add to the message (most headers are allowed)
  20. * - important boolean whether or not this message is important, and should be delivered ahead of non-important messages
  21. * - track_opens boolean whether or not to turn on open tracking for the message
  22. * - track_clicks boolean whether or not to turn on click tracking for the message
  23. * - auto_text boolean whether or not to automatically generate a text part for messages that are not given text
  24. * - auto_html boolean whether or not to automatically generate an HTML part for messages that are not given HTML
  25. * - inline_css boolean whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size
  26. * - url_strip_qs boolean whether or not to strip the query string from URLs when aggregating tracked URL data
  27. * - preserve_recipients boolean whether or not to expose all recipients in to "To" header for each email
  28. * - view_content_link boolean set to false to remove content logging for sensitive emails
  29. * - bcc_address string an optional address to receive an exact copy of each recipient's email
  30. * - tracking_domain string a custom domain to use for tracking opens and clicks instead of mandrillapp.com
  31. * - signing_domain string a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)
  32. * - return_path_domain string a custom domain to use for the messages's return-path
  33. * - merge boolean whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided.
  34. * - merge_language string the merge tag language to use when evaluating merge tags, either mailchimp or handlebars
  35. * - global_merge_vars array global merge variables to use for all recipients. You can override these per recipient.
  36. * - global_merge_vars[] struct a single global merge variable
  37. * - name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _
  38. * - content mixed the global merge variable's content
  39. * - merge_vars array per-recipient merge variables, which override global merge variables with the same name.
  40. * - merge_vars[] struct per-recipient merge variables
  41. * - rcpt string the email address of the recipient that the merge variables should apply to
  42. * - vars array the recipient's merge variables
  43. * - vars[] struct a single merge variable
  44. * - name string the merge variable's name. Merge variable names are case-insensitive and may not start with _
  45. * - content mixed the merge variable's content
  46. * - tags array an array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.
  47. * - tags[] string a single tag - must not start with an underscore
  48. * - subaccount string the unique id of a subaccount for this message - must already exist or will fail with an error
  49. * - google_analytics_domains array an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.
  50. * - google_analytics_campaign array|string optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.
  51. * - metadata array metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.
  52. * - recipient_metadata array Per-recipient metadata that will override the global values specified in the metadata parameter.
  53. * - recipient_metadata[] struct metadata for a single recipient
  54. * - rcpt string the email address of the recipient that the metadata is associated with
  55. * - values array an associated array containing the recipient's unique metadata. If a key exists in both the per-recipient metadata and the global metadata, the per-recipient metadata will be used.
  56. * - attachments array an array of supported attachments to add to the message
  57. * - attachments[] struct a single supported attachment
  58. * - type string the MIME type of the attachment
  59. * - name string the file name of the attachment
  60. * - content string the content of the attachment as a base64-encoded string
  61. * - images array an array of embedded images to add to the message
  62. * - images[] struct a single embedded image
  63. * - type string the MIME type of the image - must start with "image/"
  64. * - name string the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
  65. * - content string the content of the image as a base64-encoded string
  66. * @param boolean $async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
  67. * @param string $ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
  68. * @param string $send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.
  69. * @return array of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient
  70. * - return[] struct the sending results for a single recipient
  71. * - email string the email address of the recipient
  72. * - status string the sending status of the recipient - either "sent", "queued", "scheduled", "rejected", or "invalid"
  73. * - reject_reason string the reason for the rejection if the recipient status is "rejected" - one of "hard-bounce", "soft-bounce", "spam", "unsub", "custom", "invalid-sender", "invalid", "test-mode-limit", or "rule"
  74. * - _id string the message's unique id
  75. */
  76. public function send($message, $async=false, $ip_pool=null, $send_at=null) {
  77. $_params = array("message" => $message, "async" => $async, "ip_pool" => $ip_pool, "send_at" => $send_at);
  78. return $this->master->call('messages/send', $_params);
  79. }
  80. /**
  81. * Send a new transactional message through Mandrill using a template
  82. * @param string $template_name the immutable name or slug of a template that exists in the user's account. For backwards-compatibility, the template name may also be used but the immutable slug is preferred.
  83. * @param array $template_content an array of template content to send. Each item in the array should be a struct with two keys - name: the name of the content block to set the content for, and content: the actual content to put into the block
  84. * - template_content[] struct the injection of a single piece of content into a single editable region
  85. * - name string the name of the mc:edit editable region to inject into
  86. * - content string the content to inject
  87. * @param struct $message the other information on the message to send - same as /messages/send, but without the html content
  88. * - html string optional full HTML content to be sent if not in template
  89. * - text string optional full text content to be sent
  90. * - subject string the message subject
  91. * - from_email string the sender email address.
  92. * - from_name string optional from name to be used
  93. * - to array an array of recipient information.
  94. * - to[] struct a single recipient's information.
  95. * - email string the email address of the recipient
  96. * - name string the optional display name to use for the recipient
  97. * - type string the header type to use for the recipient, defaults to "to" if not provided
  98. * - headers struct optional extra headers to add to the message (most headers are allowed)
  99. * - important boolean whether or not this message is important, and should be delivered ahead of non-important messages
  100. * - track_opens boolean whether or not to turn on open tracking for the message
  101. * - track_clicks boolean whether or not to turn on click tracking for the message
  102. * - auto_text boolean whether or not to automatically generate a text part for messages that are not given text
  103. * - auto_html boolean whether or not to automatically generate an HTML part for messages that are not given HTML
  104. * - inline_css boolean whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size
  105. * - url_strip_qs boolean whether or not to strip the query string from URLs when aggregating tracked URL data
  106. * - preserve_recipients boolean whether or not to expose all recipients in to "To" header for each email
  107. * - view_content_link boolean set to false to remove content logging for sensitive emails
  108. * - bcc_address string an optional address to receive an exact copy of each recipient's email
  109. * - tracking_domain string a custom domain to use for tracking opens and clicks instead of mandrillapp.com
  110. * - signing_domain string a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)
  111. * - return_path_domain string a custom domain to use for the messages's return-path
  112. * - merge boolean whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided.
  113. * - merge_language string the merge tag language to use when evaluating merge tags, either mailchimp or handlebars
  114. * - global_merge_vars array global merge variables to use for all recipients. You can override these per recipient.
  115. * - global_merge_vars[] struct a single global merge variable
  116. * - name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _
  117. * - content mixed the global merge variable's content
  118. * - merge_vars array per-recipient merge variables, which override global merge variables with the same name.
  119. * - merge_vars[] struct per-recipient merge variables
  120. * - rcpt string the email address of the recipient that the merge variables should apply to
  121. * - vars array the recipient's merge variables
  122. * - vars[] struct a single merge variable
  123. * - name string the merge variable's name. Merge variable names are case-insensitive and may not start with _
  124. * - content mixed the merge variable's content
  125. * - tags array an array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.
  126. * - tags[] string a single tag - must not start with an underscore
  127. * - subaccount string the unique id of a subaccount for this message - must already exist or will fail with an error
  128. * - google_analytics_domains array an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.
  129. * - google_analytics_campaign array|string optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.
  130. * - metadata array metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.
  131. * - recipient_metadata array Per-recipient metadata that will override the global values specified in the metadata parameter.
  132. * - recipient_metadata[] struct metadata for a single recipient
  133. * - rcpt string the email address of the recipient that the metadata is associated with
  134. * - values array an associated array containing the recipient's unique metadata. If a key exists in both the per-recipient metadata and the global metadata, the per-recipient metadata will be used.
  135. * - attachments array an array of supported attachments to add to the message
  136. * - attachments[] struct a single supported attachment
  137. * - type string the MIME type of the attachment
  138. * - name string the file name of the attachment
  139. * - content string the content of the attachment as a base64-encoded string
  140. * - images array an array of embedded images to add to the message
  141. * - images[] struct a single embedded image
  142. * - type string the MIME type of the image - must start with "image/"
  143. * - name string the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
  144. * - content string the content of the image as a base64-encoded string
  145. * @param boolean $async enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
  146. * @param string $ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
  147. * @param string $send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.
  148. * @return array of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient
  149. * - return[] struct the sending results for a single recipient
  150. * - email string the email address of the recipient
  151. * - status string the sending status of the recipient - either "sent", "queued", "rejected", or "invalid"
  152. * - reject_reason string the reason for the rejection if the recipient status is "rejected" - one of "hard-bounce", "soft-bounce", "spam", "unsub", "custom", "invalid-sender", "invalid", "test-mode-limit", or "rule"
  153. * - _id string the message's unique id
  154. */
  155. public function sendTemplate($template_name, $template_content, $message, $async=false, $ip_pool=null, $send_at=null) {
  156. $_params = array("template_name" => $template_name, "template_content" => $template_content, "message" => $message, "async" => $async, "ip_pool" => $ip_pool, "send_at" => $send_at);
  157. return $this->master->call('messages/send-template', $_params);
  158. }
  159. /**
  160. * Search recently sent messages and optionally narrow by date range, tags, senders, and API keys. If no date range is specified, results within the last 7 days are returned. This method may be called up to 20 times per minute. If you need the data more often, you can use <a href="/api/docs/messages.html#method=info">/messages/info.json</a> to get the information for a single message, or <a href="http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks">webhooks</a> to push activity to your own application for querying.
  161. * @param string $query <a href="http://help.mandrill.com/entries/22211902">search terms</a> to find matching messages
  162. * @param string $date_from start date
  163. * @param string $date_to end date
  164. * @param array $tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags
  165. * @param array $senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders
  166. * @param array $api_keys an array of API keys to narrow the search to, will return messages sent by ANY of the keys
  167. * @param integer $limit the maximum number of results to return, defaults to 100, 1000 is the maximum
  168. * @return array of structs for each matching message
  169. * - return[] struct the information for a single matching message
  170. * - ts integer the Unix timestamp from when this message was sent
  171. * - _id string the message's unique id
  172. * - sender string the email address of the sender
  173. * - template string the unique name of the template used, if any
  174. * - subject string the message's subject line
  175. * - email string the recipient email address
  176. * - tags array list of tags on this message
  177. * - tags[] string individual tag on this message
  178. * - opens integer how many times has this message been opened
  179. * - opens_detail array list of individual opens for the message
  180. * - opens_detail[] struct information on an individual open
  181. * - ts integer the unix timestamp from when the message was opened
  182. * - ip string the IP address that generated the open
  183. * - location string the approximate region and country that the opening IP is located
  184. * - ua string the email client or browser data of the open
  185. * - clicks integer how many times has a link been clicked in this message
  186. * - clicks_detail array list of individual clicks for the message
  187. * - clicks_detail[] struct information on an individual click
  188. * - ts integer the unix timestamp from when the message was clicked
  189. * - url string the URL that was clicked on
  190. * - ip string the IP address that generated the click
  191. * - location string the approximate region and country that the clicking IP is located
  192. * - ua string the email client or browser data of the click
  193. * - state string sending status of this message: sent, bounced, rejected
  194. * - metadata struct any custom metadata provided when the message was sent
  195. * - smtp_events array a log of up to 3 smtp events for the message
  196. * - smtp_events[] struct information about a specific smtp event
  197. * - ts integer the Unix timestamp when the event occured
  198. * - type string the message's state as a result of this event
  199. * - diag string the SMTP response from the recipient's server
  200. */
  201. public function search($query='*', $date_from=null, $date_to=null, $tags=null, $senders=null, $api_keys=null, $limit=100) {
  202. $_params = array("query" => $query, "date_from" => $date_from, "date_to" => $date_to, "tags" => $tags, "senders" => $senders, "api_keys" => $api_keys, "limit" => $limit);
  203. return $this->master->call('messages/search', $_params);
  204. }
  205. /**
  206. * Search the content of recently sent messages and return the aggregated hourly stats for matching messages
  207. * @param string $query the search terms to find matching messages for
  208. * @param string $date_from start date
  209. * @param string $date_to end date
  210. * @param array $tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags
  211. * @param array $senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders
  212. * @return array the array of history information
  213. * - return[] struct the stats for a single hour
  214. * - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
  215. * - sent integer the number of emails that were sent during the hour
  216. * - hard_bounces integer the number of emails that hard bounced during the hour
  217. * - soft_bounces integer the number of emails that soft bounced during the hour
  218. * - rejects integer the number of emails that were rejected during the hour
  219. * - complaints integer the number of spam complaints received during the hour
  220. * - unsubs integer the number of unsubscribes received during the hour
  221. * - opens integer the number of emails opened during the hour
  222. * - unique_opens integer the number of unique opens generated by messages sent during the hour
  223. * - clicks integer the number of tracked URLs clicked during the hour
  224. * - unique_clicks integer the number of unique clicks generated by messages sent during the hour
  225. */
  226. public function searchTimeSeries($query='*', $date_from=null, $date_to=null, $tags=null, $senders=null) {
  227. $_params = array("query" => $query, "date_from" => $date_from, "date_to" => $date_to, "tags" => $tags, "senders" => $senders);
  228. return $this->master->call('messages/search-time-series', $_params);
  229. }
  230. /**
  231. * Get the information for a single recently sent message
  232. * @param string $id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls
  233. * @return struct the information for the message
  234. * - ts integer the Unix timestamp from when this message was sent
  235. * - _id string the message's unique id
  236. * - sender string the email address of the sender
  237. * - template string the unique name of the template used, if any
  238. * - subject string the message's subject line
  239. * - email string the recipient email address
  240. * - tags array list of tags on this message
  241. * - tags[] string individual tag on this message
  242. * - opens integer how many times has this message been opened
  243. * - opens_detail array list of individual opens for the message
  244. * - opens_detail[] struct information on an individual open
  245. * - ts integer the unix timestamp from when the message was opened
  246. * - ip string the IP address that generated the open
  247. * - location string the approximate region and country that the opening IP is located
  248. * - ua string the email client or browser data of the open
  249. * - clicks integer how many times has a link been clicked in this message
  250. * - clicks_detail array list of individual clicks for the message
  251. * - clicks_detail[] struct information on an individual click
  252. * - ts integer the unix timestamp from when the message was clicked
  253. * - url string the URL that was clicked on
  254. * - ip string the IP address that generated the click
  255. * - location string the approximate region and country that the clicking IP is located
  256. * - ua string the email client or browser data of the click
  257. * - state string sending status of this message: sent, bounced, rejected
  258. * - metadata struct any custom metadata provided when the message was sent
  259. * - smtp_events array a log of up to 3 smtp events for the message
  260. * - smtp_events[] struct information about a specific smtp event
  261. * - ts integer the Unix timestamp when the event occured
  262. * - type string the message's state as a result of this event
  263. * - diag string the SMTP response from the recipient's server
  264. */
  265. public function info($id) {
  266. $_params = array("id" => $id);
  267. return $this->master->call('messages/info', $_params);
  268. }
  269. /**
  270. * Get the full content of a recently sent message
  271. * @param string $id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls
  272. * @return struct the content of the message
  273. * - ts integer the Unix timestamp from when this message was sent
  274. * - _id string the message's unique id
  275. * - from_email string the email address of the sender
  276. * - from_name string the alias of the sender (if any)
  277. * - subject string the message's subject line
  278. * - to struct the message recipient's information
  279. * - email string the email address of the recipient
  280. * - name string the alias of the recipient (if any)
  281. * - tags array list of tags on this message
  282. * - tags[] string individual tag on this message
  283. * - headers struct the key-value pairs of the custom MIME headers for the message's main document
  284. * - text string the text part of the message, if any
  285. * - html string the HTML part of the message, if any
  286. * - attachments array an array of any attachments that can be found in the message
  287. * - attachments[] struct information about an individual attachment
  288. * - name string the file name of the attachment
  289. * - type string the MIME type of the attachment
  290. * - content string the content of the attachment as a base64 encoded string
  291. */
  292. public function content($id) {
  293. $_params = array("id" => $id);
  294. return $this->master->call('messages/content', $_params);
  295. }
  296. /**
  297. * Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces
  298. * @param string $raw_message the full MIME document of an email message
  299. * @return struct the parsed message
  300. * - subject string the subject of the message
  301. * - from_email string the email address of the sender
  302. * - from_name string the alias of the sender (if any)
  303. * - to array an array of any recipients in the message
  304. * - to[] struct the information on a single recipient
  305. * - email string the email address of the recipient
  306. * - name string the alias of the recipient (if any)
  307. * - headers struct the key-value pairs of the MIME headers for the message's main document
  308. * - text string the text part of the message, if any
  309. * - html string the HTML part of the message, if any
  310. * - attachments array an array of any attachments that can be found in the message
  311. * - attachments[] struct information about an individual attachment
  312. * - name string the file name of the attachment
  313. * - type string the MIME type of the attachment
  314. * - binary boolean if this is set to true, the attachment is not pure-text, and the content will be base64 encoded
  315. * - content string the content of the attachment as a text string or a base64 encoded string based on the attachment type
  316. * - images array an array of any embedded images that can be found in the message
  317. * - images[] struct information about an individual image
  318. * - name string the Content-ID of the embedded image
  319. * - type string the MIME type of the image
  320. * - content string the content of the image as a base64 encoded string
  321. */
  322. public function parse($raw_message) {
  323. $_params = array("raw_message" => $raw_message);
  324. return $this->master->call('messages/parse', $_params);
  325. }
  326. /**
  327. * Take a raw MIME document for a message, and send it exactly as if it were sent through Mandrill's SMTP servers
  328. * @param string $raw_message the full MIME document of an email message
  329. * @param string|null $from_email optionally define the sender address - otherwise we'll use the address found in the provided headers
  330. * @param string|null $from_name optionally define the sender alias
  331. * @param array|null $to optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document
  332. * - to[] string the email address of the recipient
  333. * @param boolean $async enable a background sending mode that is optimized for bulk sending. In async mode, messages/sendRaw will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the 'reject' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.
  334. * @param string $ip_pool the name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.
  335. * @param string $send_at when this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately.
  336. * @param string $return_path_domain a custom domain to use for the messages's return-path
  337. * @return array of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient
  338. * - return[] struct the sending results for a single recipient
  339. * - email string the email address of the recipient
  340. * - status string the sending status of the recipient - either "sent", "queued", "scheduled", "rejected", or "invalid"
  341. * - reject_reason string the reason for the rejection if the recipient status is "rejected" - one of "hard-bounce", "soft-bounce", "spam", "unsub", "custom", "invalid-sender", "invalid", "test-mode-limit", or "rule"
  342. * - _id string the message's unique id
  343. */
  344. public function sendRaw($raw_message, $from_email=null, $from_name=null, $to=null, $async=false, $ip_pool=null, $send_at=null, $return_path_domain=null) {
  345. $_params = array("raw_message" => $raw_message, "from_email" => $from_email, "from_name" => $from_name, "to" => $to, "async" => $async, "ip_pool" => $ip_pool, "send_at" => $send_at, "return_path_domain" => $return_path_domain);
  346. return $this->master->call('messages/send-raw', $_params);
  347. }
  348. /**
  349. * Queries your scheduled emails.
  350. * @param string $to an optional recipient address to restrict results to
  351. * @return array a list of up to 1000 scheduled emails
  352. * - return[] struct a scheduled email
  353. * - _id string the scheduled message id
  354. * - created_at string the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
  355. * - send_at string the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
  356. * - from_email string the email's sender address
  357. * - to string the email's recipient
  358. * - subject string the email's subject
  359. */
  360. public function listScheduled($to=null) {
  361. $_params = array("to" => $to);
  362. return $this->master->call('messages/list-scheduled', $_params);
  363. }
  364. /**
  365. * Cancels a scheduled email.
  366. * @param string $id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
  367. * @return struct information about the scheduled email that was cancelled.
  368. * - _id string the scheduled message id
  369. * - created_at string the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
  370. * - send_at string the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
  371. * - from_email string the email's sender address
  372. * - to string the email's recipient
  373. * - subject string the email's subject
  374. */
  375. public function cancelScheduled($id) {
  376. $_params = array("id" => $id);
  377. return $this->master->call('messages/cancel-scheduled', $_params);
  378. }
  379. /**
  380. * Reschedules a scheduled email.
  381. * @param string $id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
  382. * @param string $send_at the new UTC timestamp when the message should sent. Mandrill can't time travel, so if you specify a time in past the message will be sent immediately
  383. * @return struct information about the scheduled email that was rescheduled.
  384. * - _id string the scheduled message id
  385. * - created_at string the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
  386. * - send_at string the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
  387. * - from_email string the email's sender address
  388. * - to string the email's recipient
  389. * - subject string the email's subject
  390. */
  391. public function reschedule($id, $send_at) {
  392. $_params = array("id" => $id, "send_at" => $send_at);
  393. return $this->master->call('messages/reschedule', $_params);
  394. }
  395. }