Passed
Push — master ( d156dd...acd975 )
by Thomas
04:20 queued 01:05
created

Mandrill_Messages::reschedule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
class Mandrill_Messages
4
{
5
6
    public function __construct(Mandrill $master)
7
    {
8
        $this->master = $master;
0 ignored issues
show
Bug Best Practice introduced by
The property master does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
9
    }
10
11
    /**
12
     * Send a new transactional message through Mandrill
13
     * @param array $message the information on the message to send
14
     *     - html string the full HTML content to be sent
15
     *     - text string optional full text content to be sent
16
     *     - subject string the message subject
17
     *     - from_email string the sender email address.
18
     *     - from_name string optional from name to be used
19
     *     - to array an array of recipient information.
20
     *         - to[] struct a single recipient's information.
21
     *             - email string the email address of the recipient
22
     *             - name string the optional display name to use for the recipient
23
     *             - type string the header type to use for the recipient, defaults to "to" if not provided
24
     *     - headers struct optional extra headers to add to the message (most headers are allowed)
25
     *     - important boolean whether or not this message is important, and should be delivered ahead of non-important messages
26
     *     - track_opens boolean whether or not to turn on open tracking for the message
27
     *     - track_clicks boolean whether or not to turn on click tracking for the message
28
     *     - auto_text boolean whether or not to automatically generate a text part for messages that are not given text
29
     *     - auto_html boolean whether or not to automatically generate an HTML part for messages that are not given HTML
30
     *     - 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
31
     *     - url_strip_qs boolean whether or not to strip the query string from URLs when aggregating tracked URL data
32
     *     - preserve_recipients boolean whether or not to expose all recipients in to "To" header for each email
33
     *     - view_content_link boolean set to false to remove content logging for sensitive emails
34
     *     - bcc_address string an optional address to receive an exact copy of each recipient's email
35
     *     - tracking_domain string a custom domain to use for tracking opens and clicks instead of mandrillapp.com
36
     *     - signing_domain string a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)
37
     *     - return_path_domain string a custom domain to use for the messages's return-path
38
     *     - 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.
39
     *     - merge_language string the merge tag language to use when evaluating merge tags, either mailchimp or handlebars
40
     *     - global_merge_vars array global merge variables to use for all recipients. You can override these per recipient.
41
     *         - global_merge_vars[] struct a single global merge variable
42
     *             - name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _
43
     *             - content mixed the global merge variable's content
44
     *     - merge_vars array per-recipient merge variables, which override global merge variables with the same name.
45
     *         - merge_vars[] struct per-recipient merge variables
46
     *             - rcpt string the email address of the recipient that the merge variables should apply to
47
     *             - vars array the recipient's merge variables
48
     *                 - vars[] struct a single merge variable
49
     *                     - name string the merge variable's name. Merge variable names are case-insensitive and may not start with _
50
     *                     - content mixed the merge variable's content
51
     *     - 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.
52
     *         - tags[] string a single tag - must not start with an underscore
53
     *     - subaccount string the unique id of a subaccount for this message - must already exist or will fail with an error
54
     *     - 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.
55
     *     - 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.
56
     *     - 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.
57
     *     - recipient_metadata array Per-recipient metadata that will override the global values specified in the metadata parameter.
58
     *         - recipient_metadata[] struct metadata for a single recipient
59
     *             - rcpt string the email address of the recipient that the metadata is associated with
60
     *             - 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.
61
     *     - attachments array an array of supported attachments to add to the message
62
     *         - attachments[] struct a single supported attachment
63
     *             - type string the MIME type of the attachment
64
     *             - name string the file name of the attachment
65
     *             - content string the content of the attachment as a base64-encoded string
66
     *     - images array an array of embedded images to add to the message
67
     *         - images[] struct a single embedded image
68
     *             - type string the MIME type of the image - must start with "image/"
69
     *             - name string the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
70
     *             - content string the content of the image as a base64-encoded string
71
     * @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.
72
     * @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.
73
     * @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.
74
     * @return array of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient
75
     *     - return[] struct the sending results for a single recipient
76
     *         - email string the email address of the recipient
77
     *         - status string the sending status of the recipient - either "sent", "queued", "scheduled", "rejected", or "invalid"
78
     *         - 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"
79
     *         - _id string the message's unique id
80
     */
81
    public function send($message, $async = false, $ip_pool = null, $send_at = null)
82
    {
83
        $_params = array("message" => $message, "async" => $async, "ip_pool" => $ip_pool, "send_at" => $send_at);
84
        return $this->master->call('messages/send', $_params);
85
    }
86
87
    /**
88
     * Send a new transactional message through Mandrill using a template
89
     * @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.
90
     * @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
91
     *     - template_content[] struct the injection of a single piece of content into a single editable region
92
     *         - name string the name of the mc:edit editable region to inject into
93
     *         - content string the content to inject
94
     * @param struct $message the other information on the message to send - same as /messages/send, but without the html content
0 ignored issues
show
Bug introduced by
The type struct was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
95
     *     - html string optional full HTML content to be sent if not in template
96
     *     - text string optional full text content to be sent
97
     *     - subject string the message subject
98
     *     - from_email string the sender email address.
99
     *     - from_name string optional from name to be used
100
     *     - to array an array of recipient information.
101
     *         - to[] struct a single recipient's information.
102
     *             - email string the email address of the recipient
103
     *             - name string the optional display name to use for the recipient
104
     *             - type string the header type to use for the recipient, defaults to "to" if not provided
105
     *     - headers struct optional extra headers to add to the message (most headers are allowed)
106
     *     - important boolean whether or not this message is important, and should be delivered ahead of non-important messages
107
     *     - track_opens boolean whether or not to turn on open tracking for the message
108
     *     - track_clicks boolean whether or not to turn on click tracking for the message
109
     *     - auto_text boolean whether or not to automatically generate a text part for messages that are not given text
110
     *     - auto_html boolean whether or not to automatically generate an HTML part for messages that are not given HTML
111
     *     - 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
112
     *     - url_strip_qs boolean whether or not to strip the query string from URLs when aggregating tracked URL data
113
     *     - preserve_recipients boolean whether or not to expose all recipients in to "To" header for each email
114
     *     - view_content_link boolean set to false to remove content logging for sensitive emails
115
     *     - bcc_address string an optional address to receive an exact copy of each recipient's email
116
     *     - tracking_domain string a custom domain to use for tracking opens and clicks instead of mandrillapp.com
117
     *     - signing_domain string a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)
118
     *     - return_path_domain string a custom domain to use for the messages's return-path
119
     *     - 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.
120
     *     - merge_language string the merge tag language to use when evaluating merge tags, either mailchimp or handlebars
121
     *     - global_merge_vars array global merge variables to use for all recipients. You can override these per recipient.
122
     *         - global_merge_vars[] struct a single global merge variable
123
     *             - name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _
124
     *             - content mixed the global merge variable's content
125
     *     - merge_vars array per-recipient merge variables, which override global merge variables with the same name.
126
     *         - merge_vars[] struct per-recipient merge variables
127
     *             - rcpt string the email address of the recipient that the merge variables should apply to
128
     *             - vars array the recipient's merge variables
129
     *                 - vars[] struct a single merge variable
130
     *                     - name string the merge variable's name. Merge variable names are case-insensitive and may not start with _
131
     *                     - content mixed the merge variable's content
132
     *     - 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.
133
     *         - tags[] string a single tag - must not start with an underscore
134
     *     - subaccount string the unique id of a subaccount for this message - must already exist or will fail with an error
135
     *     - 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.
136
     *     - 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.
137
     *     - 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.
138
     *     - recipient_metadata array Per-recipient metadata that will override the global values specified in the metadata parameter.
139
     *         - recipient_metadata[] struct metadata for a single recipient
140
     *             - rcpt string the email address of the recipient that the metadata is associated with
141
     *             - 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.
142
     *     - attachments array an array of supported attachments to add to the message
143
     *         - attachments[] struct a single supported attachment
144
     *             - type string the MIME type of the attachment
145
     *             - name string the file name of the attachment
146
     *             - content string the content of the attachment as a base64-encoded string
147
     *     - images array an array of embedded images to add to the message
148
     *         - images[] struct a single embedded image
149
     *             - type string the MIME type of the image - must start with "image/"
150
     *             - name string the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
151
     *             - content string the content of the image as a base64-encoded string
152
     * @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.
153
     * @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.
154
     * @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.
155
     * @return array of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient
156
     *     - return[] struct the sending results for a single recipient
157
     *         - email string the email address of the recipient
158
     *         - status string the sending status of the recipient - either "sent", "queued", "rejected", or "invalid"
159
     *         - 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"
160
     *         - _id string the message's unique id
161
     */
162
    public function sendTemplate($template_name, $template_content, $message, $async = false, $ip_pool = null, $send_at = null)
163
    {
164
        $_params = array("template_name" => $template_name, "template_content" => $template_content, "message" => $message, "async" => $async, "ip_pool" => $ip_pool, "send_at" => $send_at);
165
        return $this->master->call('messages/send-template', $_params);
166
    }
167
168
    /**
169
     * 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.
170
     * @param string $query <a href="http://help.mandrill.com/entries/22211902">search terms</a> to find matching messages
171
     * @param string $date_from start date
172
     * @param string $date_to end date
173
     * @param array $tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags
174
     * @param array $senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders
175
     * @param array $api_keys an array of API keys to narrow the search to, will return messages sent by ANY of the keys
176
     * @param int $limit the maximum number of results to return, defaults to 100, 1000 is the maximum
177
     * @return array of structs for each matching message
178
     *     - return[] struct the information for a single matching message
179
     *         - ts integer the Unix timestamp from when this message was sent
180
     *         - _id string the message's unique id
181
     *         - sender string the email address of the sender
182
     *         - template string the unique name of the template used, if any
183
     *         - subject string the message's subject line
184
     *         - email string the recipient email address
185
     *         - tags array list of tags on this message
186
     *             - tags[] string individual tag on this message
187
     *         - opens integer how many times has this message been opened
188
     *         - opens_detail array list of individual opens for the message
189
     *             - opens_detail[] struct information on an individual open
190
     *                 - ts integer the unix timestamp from when the message was opened
191
     *                 - ip string the IP address that generated the open
192
     *                 - location string the approximate region and country that the opening IP is located
193
     *                 - ua string the email client or browser data of the open
194
     *         - clicks integer how many times has a link been clicked in this message
195
     *         - clicks_detail array list of individual clicks for the message
196
     *             - clicks_detail[] struct information on an individual click
197
     *                 - ts integer the unix timestamp from when the message was clicked
198
     *                 - url string the URL that was clicked on
199
     *                 - ip string the IP address that generated the click
200
     *                 - location string the approximate region and country that the clicking IP is located
201
     *                 - ua string the email client or browser data of the click
202
     *         - state string sending status of this message: sent, bounced, rejected
203
     *         - metadata struct any custom metadata provided when the message was sent
204
     *     - smtp_events array a log of up to 3 smtp events for the message
205
     *         - smtp_events[] struct information about a specific smtp event
206
     *             - ts integer the Unix timestamp when the event occured
207
     *             - type string the message's state as a result of this event
208
     *             - diag string the SMTP response from the recipient's server
209
     */
210
    public function search($query = '*', $date_from = null, $date_to = null, $tags = null, $senders = null, $api_keys = null, $limit = 100)
211
    {
212
        $_params = array("query" => $query, "date_from" => $date_from, "date_to" => $date_to, "tags" => $tags, "senders" => $senders, "api_keys" => $api_keys, "limit" => $limit);
213
        return $this->master->call('messages/search', $_params);
214
    }
215
216
    /**
217
     * Search the content of recently sent messages and return the aggregated hourly stats for matching messages
218
     * @param string $query the search terms to find matching messages for
219
     * @param string $date_from start date
220
     * @param string $date_to end date
221
     * @param array $tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags
222
     * @param array $senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders
223
     * @return array the array of history information
224
     *     - return[] struct the stats for a single hour
225
     *         - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
226
     *         - sent integer the number of emails that were sent during the hour
227
     *         - hard_bounces integer the number of emails that hard bounced during the hour
228
     *         - soft_bounces integer the number of emails that soft bounced during the hour
229
     *         - rejects integer the number of emails that were rejected during the hour
230
     *         - complaints integer the number of spam complaints received during the hour
231
     *         - unsubs integer the number of unsubscribes received during the hour
232
     *         - opens integer the number of emails opened during the hour
233
     *         - unique_opens integer the number of unique opens generated by messages sent during the hour
234
     *         - clicks integer the number of tracked URLs clicked during the hour
235
     *         - unique_clicks integer the number of unique clicks generated by messages sent during the hour
236
     */
237
    public function searchTimeSeries($query = '*', $date_from = null, $date_to = null, $tags = null, $senders = null)
238
    {
239
        $_params = array("query" => $query, "date_from" => $date_from, "date_to" => $date_to, "tags" => $tags, "senders" => $senders);
240
        return $this->master->call('messages/search-time-series', $_params);
241
    }
242
243
    /**
244
     * Get the information for a single recently sent message
245
     * @param string $id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls
246
     * @return struct the information for the message
247
     *     - ts integer the Unix timestamp from when this message was sent
248
     *     - _id string the message's unique id
249
     *     - sender string the email address of the sender
250
     *     - template string the unique name of the template used, if any
251
     *     - subject string the message's subject line
252
     *     - email string the recipient email address
253
     *     - tags array list of tags on this message
254
     *         - tags[] string individual tag on this message
255
     *     - opens integer how many times has this message been opened
256
     *     - opens_detail array list of individual opens for the message
257
     *         - opens_detail[] struct information on an individual open
258
     *             - ts integer the unix timestamp from when the message was opened
259
     *             - ip string the IP address that generated the open
260
     *             - location string the approximate region and country that the opening IP is located
261
     *             - ua string the email client or browser data of the open
262
     *     - clicks integer how many times has a link been clicked in this message
263
     *     - clicks_detail array list of individual clicks for the message
264
     *         - clicks_detail[] struct information on an individual click
265
     *             - ts integer the unix timestamp from when the message was clicked
266
     *             - url string the URL that was clicked on
267
     *             - ip string the IP address that generated the click
268
     *             - location string the approximate region and country that the clicking IP is located
269
     *             - ua string the email client or browser data of the click
270
     *     - state string sending status of this message: sent, bounced, rejected
271
     *     - metadata struct any custom metadata provided when the message was sent
272
     *     - smtp_events array a log of up to 3 smtp events for the message
273
     *         - smtp_events[] struct information about a specific smtp event
274
     *             - ts integer the Unix timestamp when the event occured
275
     *             - type string the message's state as a result of this event
276
     *             - diag string the SMTP response from the recipient's server
277
     */
278
    public function info($id)
279
    {
280
        $_params = array("id" => $id);
281
        return $this->master->call('messages/info', $_params);
282
    }
283
284
    /**
285
     * Get the full content of a recently sent message
286
     * @param string $id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls
287
     * @return struct the content of the message
288
     *     - ts integer the Unix timestamp from when this message was sent
289
     *     - _id string the message's unique id
290
     *     - from_email string the email address of the sender
291
     *     - from_name string the alias of the sender (if any)
292
     *     - subject string the message's subject line
293
     *     - to struct the message recipient's information
294
     *         - email string the email address of the recipient
295
     *         - name string the alias of the recipient (if any)
296
     *     - tags array list of tags on this message
297
     *         - tags[] string individual tag on this message
298
     *     - headers struct the key-value pairs of the custom MIME headers for the message's main document
299
     *     - text string the text part of the message, if any
300
     *     - html string the HTML part of the message, if any
301
     *     - attachments array an array of any attachments that can be found in the message
302
     *         - attachments[] struct information about an individual attachment
303
     *             - name string the file name of the attachment
304
     *             - type string the MIME type of the attachment
305
     *             - content string the content of the attachment as a base64 encoded string
306
     */
307
    public function content($id)
308
    {
309
        $_params = array("id" => $id);
310
        return $this->master->call('messages/content', $_params);
311
    }
312
313
    /**
314
     * Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces
315
     * @param string $raw_message the full MIME document of an email message
316
     * @return struct the parsed message
317
     *     - subject string the subject of the message
318
     *     - from_email string the email address of the sender
319
     *     - from_name string the alias of the sender (if any)
320
     *     - to array an array of any recipients in the message
321
     *         - to[] struct the information on a single recipient
322
     *             - email string the email address of the recipient
323
     *             - name string the alias of the recipient (if any)
324
     *     - headers struct the key-value pairs of the MIME headers for the message's main document
325
     *     - text string the text part of the message, if any
326
     *     - html string the HTML part of the message, if any
327
     *     - attachments array an array of any attachments that can be found in the message
328
     *         - attachments[] struct information about an individual attachment
329
     *             - name string the file name of the attachment
330
     *             - type string the MIME type of the attachment
331
     *             - binary boolean if this is set to true, the attachment is not pure-text, and the content will be base64 encoded
332
     *             - content string the content of the attachment as a text string or a base64 encoded string based on the attachment type
333
     *     - images array an array of any embedded images that can be found in the message
334
     *         - images[] struct information about an individual image
335
     *             - name string the Content-ID of the embedded image
336
     *             - type string the MIME type of the image
337
     *             - content string the content of the image as a base64 encoded string
338
     */
339
    public function parse($raw_message)
340
    {
341
        $_params = array("raw_message" => $raw_message);
342
        return $this->master->call('messages/parse', $_params);
343
    }
344
345
    /**
346
     * Take a raw MIME document for a message, and send it exactly as if it were sent through Mandrill's SMTP servers
347
     * @param string $raw_message the full MIME document of an email message
348
     * @param string|null $from_email optionally define the sender address - otherwise we'll use the address found in the provided headers
349
     * @param string|null $from_name optionally define the sender alias
350
     * @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
351
     *     - to[] string the email address of the recipient
352
     * @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.
353
     * @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.
354
     * @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.
355
     * @param string $return_path_domain a custom domain to use for the messages's return-path
356
     * @return array of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient
357
     *     - return[] struct the sending results for a single recipient
358
     *         - email string the email address of the recipient
359
     *         - status string the sending status of the recipient - either "sent", "queued", "scheduled", "rejected", or "invalid"
360
     *         - 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"
361
     *         - _id string the message's unique id
362
     */
363
    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)
364
    {
365
        $_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);
366
        return $this->master->call('messages/send-raw', $_params);
367
    }
368
369
    /**
370
     * Queries your scheduled emails by sender or recipient, or both.
371
     * @param string $to an optional recipient address to restrict results to
372
     * @return array a list of up to 1000 scheduled emails
373
     *     - return[] struct a scheduled email
374
     *         - _id string the scheduled message id
375
     *         - created_at string the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
376
     *         - send_at string the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
377
     *         - from_email string the email's sender address
378
     *         - to string the email's recipient
379
     *         - subject string the email's subject
380
     */
381
    public function listScheduled($to = null)
382
    {
383
        $_params = array("to" => $to);
384
        return $this->master->call('messages/list-scheduled', $_params);
385
    }
386
387
    /**
388
     * Cancels a scheduled email.
389
     * @param string $id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
390
     * @return struct information about the scheduled email that was cancelled.
391
     *     - _id string the scheduled message id
392
     *     - created_at string the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
393
     *     - send_at string the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
394
     *     - from_email string the email's sender address
395
     *     - to string the email's recipient
396
     *     - subject string the email's subject
397
     */
398
    public function cancelScheduled($id)
399
    {
400
        $_params = array("id" => $id);
401
        return $this->master->call('messages/cancel-scheduled', $_params);
402
    }
403
404
    /**
405
     * Reschedules a scheduled email.
406
     * @param string $id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled
407
     * @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
408
     * @return struct information about the scheduled email that was rescheduled.
409
     *     - _id string the scheduled message id
410
     *     - created_at string the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
411
     *     - send_at string the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
412
     *     - from_email string the email's sender address
413
     *     - to string the email's recipient
414
     *     - subject string the email's subject
415
     */
416
    public function reschedule($id, $send_at)
417
    {
418
        $_params = array("id" => $id, "send_at" => $send_at);
419
        return $this->master->call('messages/reschedule', $_params);
420
    }
421
}
422