-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add inline images in mandrill adapter #608
Merged
germsvel
merged 6 commits into
beam-community:master
from
doofinder:add-inline-images-to-mandrill
Jun 25, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e98599b
Add inline images in mandrill adapter
agutierrezrodriguez d091e77
Add check to inline images on content_type
agutierrezrodriguez c25af87
missing character
agutierrezrodriguez b967b27
typo
agutierrezrodriguez a0dcf64
Fix format too.
agutierrezrodriguez 8542fae
mix format
agutierrezrodriguez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why we're calling this
images
? Will inline attachments always be images or is that how mandrill categorizes inline attachments?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, of course! https://mailchimp.com/developer/transactional/api/messages/send-new-message/
Inside message attribute at the end.
Is similar to attachments with the difference of send the cid instead of the filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending that link. That's very helpful! This is the section I'm looking at:
Based on what I'm seeing, the changes in this PR seem good.
My only lingering question is: do you know if it's possible to add non-image files as inline attachments?
content-id
but we would incorrectly put it in the:images
field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new commit to check the content_type too before add it as inline image.