-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inline images in mandrill adapter (#608)
This commit adds support to send to mandrill images inline.
- Loading branch information
1 parent
2eb0124
commit b82c988
Showing
3 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
erlang 21.2 | ||
elixir 1.8.1 | ||
erlang 22.3.4 | ||
elixir 1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
defmodule Bamboo.MandrillAdapterTest do | ||
use ExUnit.Case | ||
alias Bamboo.Attachment | ||
alias Bamboo.Email | ||
alias Bamboo.MandrillHelper | ||
alias Bamboo.MandrillAdapter | ||
|
@@ -103,6 +104,8 @@ defmodule Bamboo.MandrillAdapterTest do | |
end | ||
|
||
test "deliver/2 sends from, html and text body, subject, headers and attachment" do | ||
file_path = Path.join(__DIR__, "../../../support/attachment.txt") | ||
|
||
email = | ||
new_email( | ||
from: {"From", "[email protected]"}, | ||
|
@@ -111,7 +114,20 @@ defmodule Bamboo.MandrillAdapterTest do | |
html_body: "HTML BODY" | ||
) | ||
|> Email.put_header("Reply-To", "[email protected]") | ||
|> Email.put_attachment(Path.join(__DIR__, "../../../support/attachment.txt")) | ||
|> Email.put_attachment(file_path) | ||
|> Email.put_attachment( | ||
Attachment.new(file_path, content_id: "my_fake_image", filename: "fake_image.jpg") | ||
) | ||
|> Email.put_attachment(%Attachment{ | ||
content_type: "image/png", | ||
content_id: "my_image", | ||
filename: "my_image.png", | ||
data: | ||
<<137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, | ||
8, 6, 0, 0, 0, 31, 21, 196, 137, 0, 0, 0, 13, 73, 68, 65, 84, 120, 218, 99, 252, 207, | ||
192, 80, 15, 0, 4, 133, 1, 128, 132, 169, 140, 33, 0, 0, 0, 0, 73, 69, 78, 68, 174, | ||
66, 96, 130>> | ||
}) | ||
|
||
email |> MandrillAdapter.deliver(@config) | ||
|
||
|
@@ -131,6 +147,20 @@ defmodule Bamboo.MandrillAdapterTest do | |
"type" => "text/plain", | ||
"name" => "attachment.txt", | ||
"content" => "VGVzdCBBdHRhY2htZW50Cg==" | ||
}, | ||
%{ | ||
"type" => "text/plain", | ||
"name" => "fake_image.jpg", | ||
"content" => "VGVzdCBBdHRhY2htZW50Cg==" | ||
} | ||
] | ||
|
||
assert message["images"] == [ | ||
%{ | ||
"type" => "image/png", | ||
"name" => "my_image", | ||
"content" => | ||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==" | ||
} | ||
] | ||
end | ||
|