Skip to content

Commit 4b087df

Browse files
Marc SuttonMarc Sutton
Marc Sutton
authored and
Marc Sutton
committed
Add support for BCCing from rails (based on the mail object). Fixes drewblas#16 on drewblas/aws-ses.
1 parent 1a6d7b8 commit 4b087df

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/aws/ses/send_email.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,20 @@ def send_raw_email(mail, args = {})
100100
package = { 'RawMessage.Data' => Base64::encode64(message) }
101101
package['Source'] = args[:from] if args[:from]
102102
package['Source'] = args[:source] if args[:source]
103+
104+
# Extract the list of recipients based on arguments or mail headers
105+
destinations = []
103106
if args[:destinations]
104-
add_array_to_hash!(package, 'Destinations', args[:destinations])
107+
destinations.concat args[:destinations].to_a
108+
elsif args[:to]
109+
destinations.concat args[:to].to_a
105110
else
106-
add_array_to_hash!(package, 'Destinations', args[:to]) if args[:to]
111+
destinations.concat mail.to.to_a
112+
destinations.concat mail.cc.to_a
113+
destinations.concat mail.bcc.to_a
107114
end
115+
add_array_to_hash!(package, 'Destinations', destinations) if destinations.length > 0
116+
108117
request('SendRawEmail', package)
109118
end
110119

0 commit comments

Comments
 (0)