Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mailgunner/client/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def send_message(attributes = ATTRIBUTES)
end

def send_mime(mail)
to = ['to', Array(mail.destinations).join(',')]
to = ['to', Array(mail.smtp_envelope_to).join(',')]

message = ['message', mail.encoded, {filename: 'message.mime'}]

Expand Down
16 changes: 16 additions & 0 deletions spec/mailgunner/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ def stub(http_method, url, body: nil, headers: nil)

client.send_mime(mail)
end

it 'overrides recipients with smtp_envelope_to when present' do
mail.to = 'alice@example.com, john@example.com'
mail.cc = 'carol@example.com, eve@example.com'
mail.bcc = 'dave@example.com, frank@example.com'

mail.smtp_envelope_to = 'alice@example.com, carol@example.com, dave@example.com'

stub(:post, "#{base_url}/v3/#{domain}/messages.mime")

recipients = 'alice@example.com, carol@example.com, dave@example.com'

Net::HTTP::Post.any_instance.expects(:set_form).with(includes(['to', recipients]), 'multipart/form-data')

client.send_mime(mail)
end
end

describe '#delete_message' do
Expand Down
Loading