Method: AWS::SimpleEmailService#send_raw_email

Defined in:
lib/aws/simple_email_service.rb

#send_raw_email(raw_message, options = {}) ⇒ nil Also known as: deliver, deliver!

Sends a raw email (email message, with header and content specified). Useful for sending multipart MIME emails. The raw text of the message must comply with Internet email standards; otherwise, the message cannot be sent.

raw = "Date: Wed, 1 Jun 2011 09:13:07 -0700\nSubject: A Sample Email\nFrom: \"John Doe\" <[email protected]>\nTo: \"Jane Doe\" <[email protected]>\nAccept-Language: en-US\nContent-Language: en-US\nContent-Type: text/plain; charset=\"utf-8\"\nContent-Transfer-Encoding: base64\nMIME-Version: 1.0\n\nc2FtcGxlIHRleHQNCg==\n"

ses.send_raw_email(raw)

Amazon SES has a limit on the total number of recipients per message: The combined number of To:, CC: and BCC: email addresses cannot exceed 50. If you need to send an email message to a larger audience, you can divide your recipient list into groups of 50 or fewer, and then call Amazon SES repeatedly to send the message to each group.

Parameters:

  • raw_message (required, String)

    The raw text of the message. You can pass in any object whos #to_s returns a valid formatted email (e.g. ruby Mail gem). The raw message should:

    • Contain a header and a body, separated by a blank line

    • Contain all required internet email headers

    • Each part of a multipart MIME message must be formatted properly

    • MIME content types must be among those supported by Amazon SES. Refer to the Amazon SES Developer Guide for more details.

    • Use content that is base64-encoded, if MIME requires it

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :to (String, Array)

    One or more email addresses to send the email to.

  • :from (String)

    The sender’s email address.

    If you specify the :from option, then bounce notifications and complaints will be sent to this email address. This takes precedence over any Return-Path header that you might include in the raw_message.

Returns:

  • (nil)


333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/aws/simple_email_service.rb', line 333

def send_raw_email raw_message, options = {}

  send_opts = {}
  send_opts[:raw_message] = {}
  send_opts[:raw_message][:data] = raw_message.to_s
  send_opts[:source] = options[:from] if options[:from]

  if raw_message.respond_to?(:destinations)
    send_opts[:destinations] = raw_message.destinations
  end
  send_opts[:destinations] = [options[:to]].flatten if options[:to]

  client.send_raw_email(send_opts)
  nil

end