71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/logstash/outputs/ses.rb', line 71
def receive(event)
@logger.debug? and @logger.debug("Creating AWS SES mail with these settings : ", :message => event,:options => @options, :from => @from, :to => @to_addresses, :cc => @cc_addresses, :subject => @subject,:innerTarget => event.sprintf("%{mailTo}"))
innerTarget = @destination.dup
if event.include?('mailTo')
innerTarget[:to_addresses] = event.sprintf("%{mailTo}").split ','
@logger.debug? and @logger.debug("new mailTo address found in event,overriding target addresses", :parsed => innerTarget[:to_addresses] )
end
subject = event.sprintf(@subject)
body = event.sprintf(@body)
htmlbody = event.sprintf(@htmlbody)
message = { :subject => {:data => subject},
:body => {
:html => {:data => htmlbody },
:text => {:data => body }
}
}
begin
@logger.debug? and @logger.debug("Sending mail with these values : ", :from => @from, :to => innerTarget, :subject => @subject, :body => @body)
@ses.send_email(
:source => @from,
:destination => innerTarget,
:message => message
)
rescue => e
logger.error("Something happen while delivering an SES email", :msg => e.message)
@logger.debug? && @logger.debug("Processed event: ", :event => event)
end
end
|