Permalink
Browse files

Add support for BCCing from rails (based on the mail object). Fixes #16

… on drewblas/aws-ses.
  • Loading branch information...
1 parent 1a6d7b8 commit 4b087dfa34b38b819b01d673518b5fcad2a9fbeb @codev committed with Marc Sutton May 2, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/aws/ses/send_email.rb
View
@@ -100,11 +100,20 @@ def send_raw_email(mail, args = {})
package = { 'RawMessage.Data' => Base64::encode64(message) }
package['Source'] = args[:from] if args[:from]
package['Source'] = args[:source] if args[:source]
+
+ # Extract the list of recipients based on arguments or mail headers
+ destinations = []
if args[:destinations]
- add_array_to_hash!(package, 'Destinations', args[:destinations])
+ destinations.concat args[:destinations].to_a
+ elsif args[:to]
+ destinations.concat args[:to].to_a
else
- add_array_to_hash!(package, 'Destinations', args[:to]) if args[:to]
+ destinations.concat mail.to.to_a
+ destinations.concat mail.cc.to_a
+ destinations.concat mail.bcc.to_a
end
+ add_array_to_hash!(package, 'Destinations', destinations) if destinations.length > 0
+
request('SendRawEmail', package)
end

0 comments on commit 4b087df

Please sign in to comment.