Issues (54)

src/thirdparty/Mandrill/Messages.php (1 issue)

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