File: send_raw_email.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (39 lines) | stat: -rw-r--r-- 1,321 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Fog
  module AWS
    class SES
      class Real
        require 'fog/aws/parsers/ses/send_raw_email'

        # Send a raw email
        #
        # ==== Parameters
        # * RawMessage <~String> - The message to be sent.
        # * Options <~Hash>
        #   * Source <~String> - The sender's email address. Takes precenence over Return-Path if specified in RawMessage
        #   * Destinations <~Array> - All destinations for this email.
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'MessageId'<~String> - Id of message
        #     * 'ResponseMetadata'<~Hash>:
        #       * 'RequestId'<~String> - Id of request
        def send_raw_email(raw_message, options = {})
          params = {}
          if options.key?('Destinations')
            params.merge!(Fog::AWS.indexed_param('Destinations.member', [*options['Destinations']]))
          end
          if options.key?('Source')
            params['Source'] = options['Source']
          end

          request({
            'Action'          => 'SendRawEmail',
            'RawMessage.Data' => Base64.encode64(raw_message.to_s).chomp!,
            :parser           => Fog::Parsers::AWS::SES::SendRawEmail.new
          }.merge(params))
        end
      end
    end
  end
end