swoosh
swoosh copied to clipboard
Error on send email with attachment
Describe the bug
After the update from 1.15.3 to 1.16.3, I am getting errors using the Mailgun adapter when include the email attachments:
(UndefinedFunctionError) function Multipart.Part.file_content_field/5 is undefined or private\\n (multipart 0.4.0) Multipart.Part.file_content_field(\\\"Evercam Dublin Office I--2024-Mar-28--22:46.jpg\\\", <<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255, 254, 0, 16, 76, 97, 118, , 21, 24, ...>>, \\\"attachment\\\", [], [content_type: \\\"image/jpeg\\\"])
Steps to Reproduce the Bug or Issue
Easy to reproduce this error. Just include attachments.
Expected behavior
No response
Your reproducible example
No response
Screenshots or Videos
No response
Platform
- OTP: 24.0
- Elixir: 1.14.0
Additional context
We just downgraded swoosh to 1.15.3 it started working again. It means this error especially happened after rewriting multipart in 1.16.1
Now it needs a new dependency, :multipart
For mailgun.
I already included :multipart dependency and got the same error.
Is there anything I need to change in my code?
I don't see any required changes in the doc.
No change in code needed. Please try removing deps and _build directories.
Same error
(UndefinedFunctionError) function Multipart.Part.file_content_field/5 is undefined or private
Hmm, I'm currently travelling with very bad internet. I'll have to look into it next week after Easter break. @krainboltgreene would you be interested in having a look?
We should have a test case for this. I'll look into it today.
Hi @azharmalik3 , I just manually tested this case |> attachment, with Swoosh.Attachment.new, with {:data, ...} and :inline. It sent without a problem for me. Could you provide a minimal reproduction repo for this issue? Thanks.
Okay so the function definition is https://hexdocs.pm/multipart/Multipart.Part.html#file_content_field/5 and the call site is https://github.com/swoosh/swoosh/blob/main/lib/swoosh/adapters/mailgun.ex#L195-L203 and the error details:
Multipart.Part.file_content_field(
\\\"Evercam Dublin Office I--2024-Mar-28--22:46.jpg\\\",
<<255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 2, 0, 0, 1, 0, 1, 0, 0, 255, 254, 0, 16, 76, 97, 118, , 21, 24, ...>>,
\\\"attachment\\\",
[],
[content_type: \\\"image/jpeg\\\"]
)
So this directly matches the signature of the function both in arguments and type.
The only way this happens is if your complication is incorrect somehow.
Issue resolved after updating to the latest version.
Thanks all.