Class: Fluent::SESOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::SESOutput
- Includes:
- Mixin::PlainTextFormatter, SetTagKeyMixin, SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_ses.rb
Instance Method Summary collapse
-
#initialize ⇒ SESOutput
constructor
A new instance of SESOutput.
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ SESOutput
Returns a new instance of SESOutput.
9 10 11 12 |
# File 'lib/fluent/plugin/out_ses.rb', line 9 def initialize super require 'aws-sdk' end |
Instance Method Details
#start ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fluent/plugin/out_ses.rb', line 29 def start super = {} if @aws_key_id && @aws_sec_key [:access_key_id] = @aws_key_id [:secret_access_key] = @aws_sec_key end @ses = AWS::SimpleEmailService.new to_addresses = @to.split "," if to_addresses.empty? raise Fluent::ConfigError, "To is not nil." end cc_addresses = @cc.split "," bcc_addresses = @bcc.split "," @destination = {:to_addresses => to_addresses} unless cc_addresses.empty? @destination[:cc_addresses] = cc_addresses end unless bcc_addresses.empty? @destination[:bcc_addresses] = bcc_addresses end valid! end |
#write(chunk) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fluent/plugin/out_ses.rb', line 56 def write(chunk) body_text = chunk.read.force_encoding "utf-8" = { :source => @from, :destination => @destination, :message => { :subject => { :data => @subject}, :body => {:text => {:data => body_text}}, }, } reply_to_addresses = @reply_to_addresses.split "," unless reply_to_addresses.empty? [:reply_to_addresses] = reply_to_addresses end begin res = @ses.client.send_email rescue => e $log.error e. end end |