Class: Mandrill::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/mandrill/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Messages

Returns a new instance of Messages.



769
770
771
# File 'lib/mandrill/api.rb', line 769

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



767
768
769
# File 'lib/mandrill/api.rb', line 767

def master
  @master
end

Instance Method Details

#cancel_scheduled(id) ⇒ Hash

Cancels a scheduled email.

Parameters:

  • id (String)

    a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled

Returns:

  • (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’s sender address

    • String

      to the email’s recipient

    • String

      subject the email’s subject



1131
1132
1133
1134
# File 'lib/mandrill/api.rb', line 1131

def cancel_scheduled(id)
    _params = {:id => id}
    return @master.call 'messages/cancel-scheduled', _params
end

#content(id) ⇒ Hash

Get the full content of a recently sent message

Parameters:

  • id (String)

    the unique id of the message to get - passed as the “_id” field in webhooks, send calls, or search calls

Returns:

  • (Hash)

    the content of the message

    • Integer

      ts the Unix timestamp from when this message was sent

    • String

      _id the message’s unique id

    • String

      from_email the email address of the sender

    • String

      from_name the alias of the sender (if any)

    • String

      subject the message’s subject line

    • Hash

      to the message recipient’s information

      - [String] email the email address of the recipient
      - [String] name the alias of the recipient (if any)
      
    • Array

      tags list of tags on this message

      - [String] tags[] individual tag on this message
      
    • Hash

      headers the key-value pairs of the custom MIME headers for the message’s main document

    • String

      text the text part of the message, if any

    • String

      html the HTML part of the message, if any

    • Array

      attachments an array of any attachments that can be found in the message

      - [Hash] attachments[] information about an individual attachment
          - [String] name the file name of the attachment
          - [String] type the MIME type of the attachment
          - [String] content the content of the attachment as a base64 encoded string
      


1052
1053
1054
1055
# File 'lib/mandrill/api.rb', line 1052

def content(id)
    _params = {:id => id}
    return @master.call 'messages/content', _params
end

#info(id) ⇒ Hash

Get the information for a single recently sent message

Parameters:

  • id (String)

    the unique id of the message to get - passed as the “_id” field in webhooks, send calls, or search calls

Returns:

  • (Hash)

    the information for the message

    • Integer

      ts the Unix timestamp from when this message was sent

    • String

      _id the message’s unique id

    • String

      sender the email address of the sender

    • String

      template the unique name of the template used, if any

    • String

      subject the message’s subject line

    • String

      email the recipient email address

    • Array

      tags list of tags on this message

      - [String] tags[] individual tag on this message
      
    • Integer

      opens how many times has this message been opened

    • Array

      opens_detail list of individual opens for the message

      - [Hash] opens_detail[] information on an individual open
          - [Integer] ts the unix timestamp from when the message was opened
          - [String] ip the IP address that generated the open
          - [String] location the approximate region and country that the opening IP is located
          - [String] ua the email client or browser data of the open
      
    • Integer

      clicks how many times has a link been clicked in this message

    • Array

      clicks_detail list of individual clicks for the message

      - [Hash] clicks_detail[] information on an individual click
          - [Integer] ts the unix timestamp from when the message was clicked
          - [String] url the URL that was clicked on
          - [String] ip the IP address that generated the click
          - [String] location the approximate region and country that the clicking IP is located
          - [String] ua the email client or browser data of the click
      
    • String

      state sending status of this message: sent, bounced, rejected

    • Hash

      metadata any custom metadata provided when the message was sent

    • Array

      smtp_events a log of up to 3 smtp events for the message

      - [Hash] smtp_events[] information about a specific smtp event
          - [Integer] ts the Unix timestamp when the event occured
          - [String] type the message's state as a result of this event
          - [String] diag the SMTP response from the recipient's server
      


1026
1027
1028
1029
# File 'lib/mandrill/api.rb', line 1026

def info(id)
    _params = {:id => id}
    return @master.call 'messages/info', _params
end

#list_scheduled(to = nil) ⇒ Array

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

Parameters:

  • to (String) (defaults to: nil)

    an optional recipient address to restrict results to

Returns:

  • (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's sender address
      - [String] to the email's recipient
      - [String] subject the email's subject
      


1117
1118
1119
1120
# File 'lib/mandrill/api.rb', line 1117

def list_scheduled(to=nil)
    _params = {:to => to}
    return @master.call 'messages/list-scheduled', _params
end

#parse(raw_message) ⇒ Hash

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

Parameters:

  • raw_message (String)

    the full MIME document of an email message

Returns:

  • (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’s main document

    • String

      text the text part of the message, if any

    • String

      html the HTML part of the message, if any

    • Array

      attachments an array of any attachments that can be found in the message

      - [Hash] attachments[] information about an individual attachment
          - [String] name the file name of the attachment
          - [String] type the MIME type of the attachment
          - [Boolean] binary if this is set to true, the attachment is not pure-text, and the content will be base64 encoded
          - [String] content the content of the attachment as a text string or a base64 encoded string based on the attachment type
      
    • Array

      images an array of any embedded images that can be found in the message

      - [Hash] images[] information about an individual image
          - [String] name the Content-ID of the embedded image
          - [String] type the MIME type of the image
          - [String] content the content of the image as a base64 encoded string
      


1081
1082
1083
1084
# File 'lib/mandrill/api.rb', line 1081

def parse(raw_message)
    _params = {:raw_message => raw_message}
    return @master.call 'messages/parse', _params
end

#reschedule(id, send_at) ⇒ Hash

Reschedules a scheduled email.

Parameters:

  • id (String)

    a scheduled email id, as returned by any of the messages/send calls or messages/list-scheduled

  • send_at (String)

    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

Returns:

  • (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’s sender address

    • String

      to the email’s recipient

    • String

      subject the email’s subject



1146
1147
1148
1149
# File 'lib/mandrill/api.rb', line 1146

def reschedule(id, send_at)
    _params = {:id => id, :send_at => send_at}
    return @master.call 'messages/reschedule', _params
end

#search(query = '*', date_from = nil, date_to = nil, tags = nil, senders = nil, api_keys = nil, limit = 100) ⇒ Array

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=“help.mandrill.com/entries/21738186-Introduction-to-Webhooks”>webhooks</a> to push activity to your own application for querying.

Parameters:

  • query (String) (defaults to: '*')

    <a href=“help.mandrill.com/entries/22211902”>search terms</a> to find matching messages

  • date_from (String) (defaults to: nil)

    start date

  • date_to (String) (defaults to: nil)

    end date

  • tags (Array) (defaults to: nil)

    an array of tag names to narrow the search to, will return messages that contain ANY of the tags

  • senders (Array) (defaults to: nil)

    an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders

  • api_keys (Array) (defaults to: nil)

    an array of API keys to narrow the search to, will return messages sent by ANY of the keys

  • limit (Integer) (defaults to: 100)

    the maximum number of results to return, defaults to 100, 1000 is the maximum

Returns:

  • (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's unique id
      - [String] sender the email address of the sender
      - [String] template the unique name of the template used, if any
      - [String] subject the message's subject line
      - [String] email the recipient email address
      - [Array] tags list of tags on this message
          - [String] tags[] individual tag on this message
      - [Integer] opens how many times has this message been opened
      - [Array] opens_detail list of individual opens for the message
          - [Hash] opens_detail[] information on an individual open
              - [Integer] ts the unix timestamp from when the message was opened
              - [String] ip the IP address that generated the open
              - [String] location the approximate region and country that the opening IP is located
              - [String] ua the email client or browser data of the open
      - [Integer] clicks how many times has a link been clicked in this message
      - [Array] clicks_detail list of individual clicks for the message
          - [Hash] clicks_detail[] information on an individual click
              - [Integer] ts the unix timestamp from when the message was clicked
              - [String] url the URL that was clicked on
              - [String] ip the IP address that generated the click
              - [String] location the approximate region and country that the clicking IP is located
              - [String] ua the email client or browser data of the click
      - [String] state sending status of this message: sent, bounced, rejected
      - [Hash] metadata any custom metadata provided when the message was sent
      
    • Array

      smtp_events a log of up to 3 smtp events for the message

      - [Hash] smtp_events[] information about a specific smtp event
          - [Integer] ts the Unix timestamp when the event occured
          - [String] type the message's state as a result of this event
          - [String] diag the SMTP response from the recipient's server
      


964
965
966
967
# File 'lib/mandrill/api.rb', line 964

def search(query='*', date_from=nil, date_to=nil, tags=nil, senders=nil, api_keys=nil, limit=100)
    _params = {:query => query, :date_from => date_from, :date_to => date_to, :tags => tags, :senders => senders, :api_keys => api_keys, :limit => limit}
    return @master.call 'messages/search', _params
end

#search_time_series(query = '*', date_from = nil, date_to = nil, tags = nil, senders = nil) ⇒ Array

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

Parameters:

  • query (String) (defaults to: '*')

    the search terms to find matching messages for

  • date_from (String) (defaults to: nil)

    start date

  • date_to (String) (defaults to: nil)

    end date

  • tags (Array) (defaults to: nil)

    an array of tag names to narrow the search to, will return messages that contain ANY of the tags

  • senders (Array) (defaults to: nil)

    an array of sender addresses to narrow the search to, will return messages sent by ANY of the senders

Returns:

  • (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
      


988
989
990
991
# File 'lib/mandrill/api.rb', line 988

def search_time_series(query='*', date_from=nil, date_to=nil, tags=nil, senders=nil)
    _params = {:query => query, :date_from => date_from, :date_to => date_to, :tags => tags, :senders => senders}
    return @master.call 'messages/search-time-series', _params
end

#send(message, async = false, ip_pool = nil, send_at = nil) ⇒ Array

Send a new transactional message through Mandrill

Parameters:

  • message (Hash)

    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's information.
          - [String] email the email address of the recipient
          - [String] name the optional display name to use for the recipient
          - [String] type the header type to use for the recipient, defaults to "to" if not provided
      
    • Hash

      headers optional extra headers to add to the message (most headers are allowed)

    • Boolean

      important whether or not this message is important, and should be delivered ahead of non-important messages

    • Boolean

      track_opens whether or not to turn on open tracking for the message

    • Boolean

      track_clicks whether or not to turn on click tracking for the message

    • Boolean

      auto_text whether or not to automatically generate a text part for messages that are not given text

    • Boolean

      auto_html whether or not to automatically generate an HTML part for messages that are not given HTML

    • Boolean

      inline_css whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size

    • Boolean

      url_strip_qs whether or not to strip the query string from URLs when aggregating tracked URL data

    • Boolean

      preserve_recipients whether or not to expose all recipients in to “To” header for each email

    • Boolean

      view_content_link set to false to remove content logging for sensitive emails

    • String

      bcc_address an optional address to receive an exact copy of each recipient’s email

    • String

      tracking_domain a custom domain to use for tracking opens and clicks instead of mandrillapp.com

    • String

      signing_domain a custom domain to use for SPF/DKIM signing instead of mandrill (for “via” or “on behalf of” in email clients)

    • String

      return_path_domain a custom domain to use for the messages’s return-path

    • Boolean

      merge whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided.

    • String

      merge_language the merge tag language to use when evaluating merge tags, either mailchimp or handlebars

    • Array

      global_merge_vars global merge variables to use for all recipients. You can override these per recipient.

      - [Hash] global_merge_vars[] a single global merge variable
          - [String] name the global merge variable's name. Merge variable names are case-insensitive and may not start with _
          - [Mixed] content the global merge variable's content
      
    • Array

      merge_vars per-recipient merge variables, which override global merge variables with the same name.

      - [Hash] merge_vars[] per-recipient merge variables
          - [String] rcpt the email address of the recipient that the merge variables should apply to
          - [Array] vars the recipient's merge variables
              - [Hash] vars[] a single merge variable
                  - [String] name the merge variable's name. Merge variable names are case-insensitive and may not start with _
                  - [Mixed] content the merge variable's content
      
    • Array

      tags 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.

      - [String] tags[] a single tag - must not start with an underscore
      
    • String

      subaccount the unique id of a subaccount for this message - must already exist or will fail with an error

    • Array

      google_analytics_domains an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.

    • Array, String

      google_analytics_campaign 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.

    • Array

      metadata 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.

    • Array

      recipient_metadata Per-recipient metadata that will override the global values specified in the metadata parameter.

      - [Hash] recipient_metadata[] metadata for a single recipient
          - [String] rcpt the email address of the recipient that the metadata is associated with
          - [Array] values 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.
      
    • Array

      attachments an array of supported attachments to add to the message

      - [Hash] attachments[] a single supported attachment
          - [String] type the MIME type of the attachment
          - [String] name the file name of the attachment
          - [String] content the content of the attachment as a base64-encoded string
      
    • Array

      images an array of embedded images to add to the message

      - [Hash] images[] a single embedded image
          - [String] type the MIME type of the image - must start with "image/"
          - [String] name the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
          - [String] content the content of the image as a base64-encoded string
      
  • async (Boolean) (defaults to: false)

    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.

  • ip_pool (String) (defaults to: nil)

    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.

  • send_at (String) (defaults to: nil)

    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.

Returns:

  • (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's unique id
      


841
842
843
844
# File 'lib/mandrill/api.rb', line 841

def send(message, async=false, ip_pool=nil, send_at=nil)
    _params = {:message => message, :async => async, :ip_pool => ip_pool, :send_at => send_at}
    return @master.call 'messages/send', _params
end

#send_raw(raw_message, from_email = nil, from_name = nil, to = nil, async = false, ip_pool = nil, send_at = nil, return_path_domain = nil) ⇒ Array

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

Parameters:

  • raw_message (String)

    the full MIME document of an email message

  • from_email (String, nil) (defaults to: nil)

    optionally define the sender address - otherwise we’ll use the address found in the provided headers

  • from_name (String, nil) (defaults to: nil)

    optionally define the sender alias

  • to (Array, nil) (defaults to: nil)

    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

  • async (Boolean) (defaults to: false)

    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.

  • ip_pool (String) (defaults to: nil)

    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.

  • send_at (String) (defaults to: nil)

    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.

  • return_path_domain (String) (defaults to: nil)

    a custom domain to use for the messages’s return-path

Returns:

  • (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's unique id
      


1102
1103
1104
1105
# File 'lib/mandrill/api.rb', line 1102

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)
    _params = {: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}
    return @master.call 'messages/send-raw', _params
end

#send_template(template_name, template_content, message, async = false, ip_pool = nil, send_at = nil) ⇒ Array

Send a new transactional message through Mandrill using a template

Parameters:

  • template_name (String)

    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.

  • template_content (Array)

    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
      
  • message (Hash)

    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's information.
          - [String] email the email address of the recipient
          - [String] name the optional display name to use for the recipient
          - [String] type the header type to use for the recipient, defaults to "to" if not provided
      
    • Hash

      headers optional extra headers to add to the message (most headers are allowed)

    • Boolean

      important whether or not this message is important, and should be delivered ahead of non-important messages

    • Boolean

      track_opens whether or not to turn on open tracking for the message

    • Boolean

      track_clicks whether or not to turn on click tracking for the message

    • Boolean

      auto_text whether or not to automatically generate a text part for messages that are not given text

    • Boolean

      auto_html whether or not to automatically generate an HTML part for messages that are not given HTML

    • Boolean

      inline_css whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size

    • Boolean

      url_strip_qs whether or not to strip the query string from URLs when aggregating tracked URL data

    • Boolean

      preserve_recipients whether or not to expose all recipients in to “To” header for each email

    • Boolean

      view_content_link set to false to remove content logging for sensitive emails

    • String

      bcc_address an optional address to receive an exact copy of each recipient’s email

    • String

      tracking_domain a custom domain to use for tracking opens and clicks instead of mandrillapp.com

    • String

      signing_domain a custom domain to use for SPF/DKIM signing instead of mandrill (for “via” or “on behalf of” in email clients)

    • String

      return_path_domain a custom domain to use for the messages’s return-path

    • Boolean

      merge whether to evaluate merge tags in the message. Will automatically be set to true if either merge_vars or global_merge_vars are provided.

    • String

      merge_language the merge tag language to use when evaluating merge tags, either mailchimp or handlebars

    • Array

      global_merge_vars global merge variables to use for all recipients. You can override these per recipient.

      - [Hash] global_merge_vars[] a single global merge variable
          - [String] name the global merge variable's name. Merge variable names are case-insensitive and may not start with _
          - [Mixed] content the global merge variable's content
      
    • Array

      merge_vars per-recipient merge variables, which override global merge variables with the same name.

      - [Hash] merge_vars[] per-recipient merge variables
          - [String] rcpt the email address of the recipient that the merge variables should apply to
          - [Array] vars the recipient's merge variables
              - [Hash] vars[] a single merge variable
                  - [String] name the merge variable's name. Merge variable names are case-insensitive and may not start with _
                  - [Mixed] content the merge variable's content
      
    • Array

      tags 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.

      - [String] tags[] a single tag - must not start with an underscore
      
    • String

      subaccount the unique id of a subaccount for this message - must already exist or will fail with an error

    • Array

      google_analytics_domains an array of strings indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.

    • Array, String

      google_analytics_campaign 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.

    • Array

      metadata 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.

    • Array

      recipient_metadata Per-recipient metadata that will override the global values specified in the metadata parameter.

      - [Hash] recipient_metadata[] metadata for a single recipient
          - [String] rcpt the email address of the recipient that the metadata is associated with
          - [Array] values 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.
      
    • Array

      attachments an array of supported attachments to add to the message

      - [Hash] attachments[] a single supported attachment
          - [String] type the MIME type of the attachment
          - [String] name the file name of the attachment
          - [String] content the content of the attachment as a base64-encoded string
      
    • Array

      images an array of embedded images to add to the message

      - [Hash] images[] a single embedded image
          - [String] type the MIME type of the image - must start with "image/"
          - [String] name the Content ID of the image - use <img src="cid:THIS_VALUE"> to reference the image in your HTML content
          - [String] content the content of the image as a base64-encoded string
      
  • async (Boolean) (defaults to: false)

    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.

  • ip_pool (String) (defaults to: nil)

    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.

  • send_at (String) (defaults to: nil)

    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.

Returns:

  • (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's unique id
      


919
920
921
922
# File 'lib/mandrill/api.rb', line 919

def send_template(template_name, template_content, message, async=false, ip_pool=nil, send_at=nil)
    _params = {:template_name => template_name, :template_content => template_content, :message => message, :async => async, :ip_pool => ip_pool, :send_at => send_at}
    return @master.call 'messages/send-template', _params
end