Skip to content

Mandrill_Messages

Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

Mandrill_Messages

  • Class name: Mandrill_Messages
  • Namespace:

Methods

__construct

mixed Mandrill_Messages::__construct(\Mandrill $master)
  • Visibility: public

Arguments

send

array Mandrill_Messages::send(\struct $message, boolean $async, string $ip_pool, string $send_at)

Send a new transactional message through Mandrill

  • Visibility: public

Arguments

  • $message struct - <p>the information on the message to send</p> <ul> <li>html string the full HTML content to be sent</li> <li>text string optional full text content to be sent</li> <li>subject string the message subject</li> <li>from_email string the sender email address.</li> <li>from_name string optional from name to be used</li> <li>to array an array of recipient information. <ul> <li>to[] struct a single recipient's information. <ul> <li>email string the email address of the recipient</li> <li>name string the optional display name to use for the recipient</li> <li>type string the header type to use for the recipient, defaults to "to" if not provided</li> </ul></li> </ul></li> <li>headers struct optional extra headers to add to the message (most headers are allowed)</li> <li>important boolean whether or not this message is important, and should be delivered ahead of non-important messages</li> <li>track_opens boolean whether or not to turn on open tracking for the message</li> <li>track_clicks boolean whether or not to turn on click tracking for the message</li> <li>auto_text boolean whether or not to automatically generate a text part for messages that are not given text</li> <li>auto_html boolean whether or not to automatically generate an HTML part for messages that are not given HTML</li> <li>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</li> <li>url_strip_qs boolean whether or not to strip the query string from URLs when aggregating tracked URL data</li> <li>preserve_recipients boolean whether or not to expose all recipients in to "To" header for each email</li> <li>view_content_link boolean set to false to remove content logging for sensitive emails</li> <li>bcc_address string an optional address to receive an exact copy of each recipient's email</li> <li>tracking_domain string a custom domain to use for tracking opens and clicks instead of mandrillapp.com</li> <li>signing_domain string a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)</li> <li>return_path_domain string a custom domain to use for the messages's return-path</li> <li>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.</li> <li>merge_language string the merge tag language to use when evaluating merge tags, either mailchimp or handlebars</li> <li>global_merge_vars array global merge variables to use for all recipients. You can override these per recipient. <ul> <li>global_merge_vars[] struct a single global merge variable <ul> <li>name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _</li> <li>content mixed the global merge variable's content</li> </ul></li> </ul></li> <li>merge_vars array per-recipient merge variables, which override global merge variables with the same name. <ul> <li>merge_vars[] struct per-recipient merge variables <ul> <li>rcpt string the email address of the recipient that the merge variables should apply to</li> <li>vars array the recipient's merge variables <ul> <li>vars[] struct a single merge variable <ul> <li>name string the merge variable's name. Merge variable names are case-insensitive and may not start with _</li> <li>content mixed the merge variable's content</li> </ul></li> </ul></li> </ul></li> </ul></li> <li>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. <ul> <li>tags[] string a single tag - must not start with an underscore</li> </ul></li> <li>subaccount string the unique id of a subaccount for this message - must already exist or will fail with an error</li> <li>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.</li> <li>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.</li> <li>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.</li> <li>recipient_metadata array Per-recipient metadata that will override the global values specified in the metadata parameter. <ul> <li>recipient_metadata[] struct metadata for a single recipient <ul> <li>rcpt string the email address of the recipient that the metadata is associated with</li> <li>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.</li> </ul></li> </ul></li> <li>attachments array an array of supported attachments to add to the message <ul> <li>attachments[] struct a single supported attachment <ul> <li>type string the MIME type of the attachment</li> <li>name string the file name of the attachment</li> <li>content string the content of the attachment as a base64-encoded string</li> </ul></li> </ul></li> <li>images array an array of embedded images to add to the message <ul> <li>images[] struct a single embedded image <ul> <li>type string the MIME type of the image - must start with "image/"</li> <li>name string the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content</li> <li>content string the content of the image as a base64-encoded string</li> </ul></li> </ul></li> </ul>
  • $async boolean - <p>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.</p>
  • $ip_pool string - <p>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.</p>
  • $send_at string - <p>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.</p>

sendTemplate

array Mandrill_Messages::sendTemplate(string $template_name, array $template_content, \struct $message, boolean $async, string $ip_pool, string $send_at)

Send a new transactional message through Mandrill using a template

  • Visibility: public

Arguments

  • $template_name string - <p>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.</p>
  • $template_content array - <p>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</p> <ul> <li>template_content[] struct the injection of a single piece of content into a single editable region <ul> <li>name string the name of the mc:edit editable region to inject into</li> <li>content string the content to inject</li> </ul></li> </ul>
  • $message struct - <p>the other information on the message to send - same as /messages/send, but without the html content</p> <ul> <li>html string optional full HTML content to be sent if not in template</li> <li>text string optional full text content to be sent</li> <li>subject string the message subject</li> <li>from_email string the sender email address.</li> <li>from_name string optional from name to be used</li> <li>to array an array of recipient information. <ul> <li>to[] struct a single recipient's information. <ul> <li>email string the email address of the recipient</li> <li>name string the optional display name to use for the recipient</li> <li>type string the header type to use for the recipient, defaults to "to" if not provided</li> </ul></li> </ul></li> <li>headers struct optional extra headers to add to the message (most headers are allowed)</li> <li>important boolean whether or not this message is important, and should be delivered ahead of non-important messages</li> <li>track_opens boolean whether or not to turn on open tracking for the message</li> <li>track_clicks boolean whether or not to turn on click tracking for the message</li> <li>auto_text boolean whether or not to automatically generate a text part for messages that are not given text</li> <li>auto_html boolean whether or not to automatically generate an HTML part for messages that are not given HTML</li> <li>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</li> <li>url_strip_qs boolean whether or not to strip the query string from URLs when aggregating tracked URL data</li> <li>preserve_recipients boolean whether or not to expose all recipients in to "To" header for each email</li> <li>view_content_link boolean set to false to remove content logging for sensitive emails</li> <li>bcc_address string an optional address to receive an exact copy of each recipient's email</li> <li>tracking_domain string a custom domain to use for tracking opens and clicks instead of mandrillapp.com</li> <li>signing_domain string a custom domain to use for SPF/DKIM signing instead of mandrill (for "via" or "on behalf of" in email clients)</li> <li>return_path_domain string a custom domain to use for the messages's return-path</li> <li>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.</li> <li>merge_language string the merge tag language to use when evaluating merge tags, either mailchimp or handlebars</li> <li>global_merge_vars array global merge variables to use for all recipients. You can override these per recipient. <ul> <li>global_merge_vars[] struct a single global merge variable <ul> <li>name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _</li> <li>content mixed the global merge variable's content</li> </ul></li> </ul></li> <li>merge_vars array per-recipient merge variables, which override global merge variables with the same name. <ul> <li>merge_vars[] struct per-recipient merge variables <ul> <li>rcpt string the email address of the recipient that the merge variables should apply to</li> <li>vars array the recipient's merge variables <ul> <li>vars[] struct a single merge variable <ul> <li>name string the merge variable's name. Merge variable names are case-insensitive and may not start with _</li> <li>content mixed the merge variable's content</li> </ul></li> </ul></li> </ul></li> </ul></li> <li>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. <ul> <li>tags[] string a single tag - must not start with an underscore</li> </ul></li> <li>subaccount string the unique id of a subaccount for this message - must already exist or will fail with an error</li> <li>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.</li> <li>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.</li> <li>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.</li> <li>recipient_metadata array Per-recipient metadata that will override the global values specified in the metadata parameter. <ul> <li>recipient_metadata[] struct metadata for a single recipient <ul> <li>rcpt string the email address of the recipient that the metadata is associated with</li> <li>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.</li> </ul></li> </ul></li> <li>attachments array an array of supported attachments to add to the message <ul> <li>attachments[] struct a single supported attachment <ul> <li>type string the MIME type of the attachment</li> <li>name string the file name of the attachment</li> <li>content string the content of the attachment as a base64-encoded string</li> </ul></li> </ul></li> <li>images array an array of embedded images to add to the message <ul> <li>images[] struct a single embedded image <ul> <li>type string the MIME type of the image - must start with "image/"</li> <li>name string the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content</li> <li>content string the content of the image as a base64-encoded string</li> </ul></li> </ul></li> </ul>
  • $async boolean - <p>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.</p>
  • $ip_pool string - <p>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.</p>
  • $send_at string - <p>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.</p>

search

array Mandrill_Messages::search(string $query, string $date_from, string $date_to, array $tags, array $senders, array $api_keys, integer $limit)

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 /messages/info.json to get the information for a single message, or webhooks to push activity to your own application for querying.

  • Visibility: public

Arguments

  • $query string - <p><a href="http://help.mandrill.com/entries/22211902&quot;&gt;search terms</a> to find matching messages</p>
  • $date_from string - <p>start date</p>
  • $date_to string - <p>end date</p>
  • $tags array - <p>an array of tag names to narrow the search to, will return messages that contain ANY of the tags</p>
  • $senders array - <p>an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders</p>
  • $api_keys array - <p>an array of API keys to narrow the search to, will return messages sent by ANY of the keys</p>
  • $limit integer - <p>the maximum number of results to return, defaults to 100, 1000 is the maximum</p>

searchTimeSeries

array Mandrill_Messages::searchTimeSeries(string $query, string $date_from, string $date_to, array $tags, array $senders)

Search the content of recently sent messages and return the aggregated hourly stats for matching messages

  • Visibility: public

Arguments

  • $query string - <p>the search terms to find matching messages for</p>
  • $date_from string - <p>start date</p>
  • $date_to string - <p>end date</p>
  • $tags array - <p>an array of tag names to narrow the search to, will return messages that contain ANY of the tags</p>
  • $senders array - <p>an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders</p>

info

\struct Mandrill_Messages::info(string $id)

Get the information for a single recently sent message

  • Visibility: public

Arguments

  • $id string - <p>the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls</p>

content

\struct Mandrill_Messages::content(string $id)

Get the full content of a recently sent message

  • Visibility: public

Arguments

  • $id string - <p>the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls</p>

parse

\struct Mandrill_Messages::parse(string $raw_message)

Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces

  • Visibility: public

Arguments

  • $raw_message string - <p>the full MIME document of an email message</p>

sendRaw

array Mandrill_Messages::sendRaw(string $raw_message, string|null $from_email, string|null $from_name, array|null $to, boolean $async, string $ip_pool, string $send_at, string $return_path_domain)

Take a raw MIME document for a message, and send it exactly as if it were sent through Mandrill's SMTP servers

  • Visibility: public

Arguments

  • $raw_message string - <p>the full MIME document of an email message</p>
  • $from_email string|null - <p>optionally define the sender address - otherwise we'll use the address found in the provided headers</p>
  • $from_name string|null - <p>optionally define the sender alias</p>
  • $to array|null - <p>optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document</p> <ul> <li>to[] string the email address of the recipient</li> </ul>
  • $async boolean - <p>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.</p>
  • $ip_pool string - <p>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.</p>
  • $send_at string - <p>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.</p>
  • $return_path_domain string - <p>a custom domain to use for the messages's return-path</p>

listScheduled

array Mandrill_Messages::listScheduled(string $to)

Queries your scheduled emails by sender or recipient, or both.

  • Visibility: public

Arguments

  • $to string - <p>an optional recipient address to restrict results to</p>

cancelScheduled

\struct Mandrill_Messages::cancelScheduled(string $id)

Cancels a scheduled email.

  • Visibility: public

Arguments

  • $id string - <p>a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled</p>

reschedule

\struct Mandrill_Messages::reschedule(string $id, string $send_at)

Reschedules a scheduled email.

  • Visibility: public

Arguments

  • $id string - <p>a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled</p>
  • $send_at string - <p>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</p>
Clone this wiki locally