class Mandrill::Messages

Defined in:

mandrill/api.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(master) #

[View source]

Instance Method Detail

def cancel_scheduled(id) #

Cancels a scheduled email. @param [String] id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled @return [Hash] information about the scheduled email that was cancelled.

- [String] _id the scheduled message id
- [String] created_at the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
- [String] send_at the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
- [String] from_email the email

[View source]
def content(id) #

Get the full content of a recently sent message @param [String] id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls @return [Hash] the content of the message

- [Integer] ts the Unix timestamp from when this message was sent
- [String] _id the message

[View source]
def info(id) #

Get the information for a single recently sent message @param [String] id the unique id of the message to get - passed as the "_id" field in webhooks, send calls, or search calls @return [Hash] the information for the message

- [Integer] ts the Unix timestamp from when this message was sent
- [String] _id the message

[View source]
def list_scheduled(to = nil) #

Queries your scheduled emails. @param [String] to an optional recipient address to restrict results to @return [Array] a list of up to 1000 scheduled emails

- [Hash] return[] a scheduled email
    - [String] _id the scheduled message id
    - [String] created_at the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
    - [String] send_at the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
    - [String] from_email the email

[View source]
def parse(raw_message) #

Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces @param [String] raw_message the full MIME document of an email message @return [Hash] the parsed message

- [String] subject the subject of the message
- [String] from_email the email address of the sender
- [String] from_name the alias of the sender (if any)
- [Array] to an array of any recipients in the message
    - [Hash] to[] the information on a single recipient
        - [String] email the email address of the recipient
        - [String] name the alias of the recipient (if any)
- [Hash] headers the key-value pairs of the MIME headers for the message

[View source]
def reschedule(id, send_at) #

Reschedules a scheduled email. @param [String] id a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled @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 @return [Hash] information about the scheduled email that was rescheduled.

- [String] _id the scheduled message id
- [String] created_at the UTC timestamp when the message was created, in YYYY-MM-DD HH:MM:SS format
- [String] send_at the UTC timestamp when the message will be sent, in YYYY-MM-DD HH:MM:SS format
- [String] from_email the email

[View source]
def search(query = '*', date_from = nil, date_to = nil, tags = nil, senders = nil, api_keys = nil, limit = 100) #

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. @param [String] query <a href="http://help.mandrill.com/entries/22211902">search terms</a> to find matching messages @param [String] date_from start date @param [String] date_to end date @param [Array] tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags @param [Array] senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders @param [Array] api_keys an array of API keys to narrow the search to, will return messages sent by ANY of the keys @param [Integer] limit the maximum number of results to return, defaults to 100, 1000 is the maximum @return [Array] of structs for each matching message

- [Hash] return[] the information for a single matching message
    - [Integer] ts the Unix timestamp from when this message was sent
    - [String] _id the message

[View source]
def search_time_series(query = '*', date_from = nil, date_to = nil, tags = nil, senders = nil) #

Search the content of recently sent messages and return the aggregated hourly stats for matching messages @param [String] query the search terms to find matching messages for @param [String] date_from start date @param [String] date_to end date @param [Array] tags an array of tag names to narrow the search to, will return messages that contain ANY of the tags @param [Array] senders an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders @return [Array] the array of history information

- [Hash] return[] the stats for a single hour
    - [String] time the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
    - [Integer] sent the number of emails that were sent during the hour
    - [Integer] hard_bounces the number of emails that hard bounced during the hour
    - [Integer] soft_bounces the number of emails that soft bounced during the hour
    - [Integer] rejects the number of emails that were rejected during the hour
    - [Integer] complaints the number of spam complaints received during the hour
    - [Integer] unsubs the number of unsubscribes received during the hour
    - [Integer] opens the number of emails opened during the hour
    - [Integer] unique_opens the number of unique opens generated by messages sent during the hour
    - [Integer] clicks the number of tracked URLs clicked during the hour
    - [Integer] unique_clicks the number of unique clicks generated by messages sent during the hour

[View source]
def send(message, async = false, ip_pool = nil, send_at = nil) #

Send a new transactional message through Mandrill @param [Hash] message the information on the message to send

- [String] html the full HTML content to be sent
- [String] text optional full text content to be sent
- [String] subject the message subject
- [String] from_email the sender email address.
- [String] from_name optional from name to be used
- [Array] to an array of recipient information.
    - [Hash] to[] a single recipient

@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. @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. @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. @return [Array] of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient

- [Hash] return[] the sending results for a single recipient
    - [String] email the email address of the recipient
    - [String] status the sending status of the recipient - either "sent", "queued", "scheduled", "rejected", or "invalid"
    - [String] reject_reason 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"
    - [String] _id the message

[View source]
def send_raw(raw_message, from_email = nil, from_name = nil, to = nil, async = false, ip_pool = nil, send_at = nil, return_path_domain = nil) #

Take a raw MIME document for a message, and send it exactly as if it were sent through Mandrill's SMTP servers @param [String] raw_message the full MIME document of an email message @param [String, nil] from_email optionally define the sender address - otherwise we'll use the address found in the provided headers @param [String, nil] from_name optionally define the sender alias @param [Array, nil] to optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document

- [String] to[] the email address of the recipient

@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. @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. @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. @param [String] return_path_domain a custom domain to use for the messages's return-path @return [Array] of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient

- [Hash] return[] the sending results for a single recipient
    - [String] email the email address of the recipient
    - [String] status the sending status of the recipient - either "sent", "queued", "scheduled", "rejected", or "invalid"
    - [String] reject_reason 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"
    - [String] _id the message

[View source]
def send_template(template_name, template_content, message, async = false, ip_pool = nil, send_at = nil) #

Send a new transactional message through Mandrill using a template @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. @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

- [Hash] template_content[] the injection of a single piece of content into a single editable region
    - [String] name the name of the mc:edit editable region to inject into
    - [String] content the content to inject

@param [Hash] message the other information on the message to send - same as /messages/send, but without the html content

- [String] html optional full HTML content to be sent if not in template
- [String] text optional full text content to be sent
- [String] subject the message subject
- [String] from_email the sender email address.
- [String] from_name optional from name to be used
- [Array] to an array of recipient information.
    - [Hash] to[] a single recipient

@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. @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. @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. @return [Array] of structs for each recipient containing the key "email" with the email address, and details of the message status for that recipient

- [Hash] return[] the sending results for a single recipient
    - [String] email the email address of the recipient
    - [String] status the sending status of the recipient - either "sent", "queued", "rejected", or "invalid"
    - [String] reject_reason 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"
    - [String] _id the message

[View source]