mailgun-ruby icon indicating copy to clipboard operation
mailgun-ruby copied to clipboard

Filename for add_attachment is not being set properly

Open matthewgani opened this issue 9 months ago • 1 comments

Hi,

I am currently using v1.3.3 and when using MessageBuilder object and adding an attachment, the filename given is not being used.

mb_obj = Mailgun::MessageBuilder.new
mb_obj.add_attachment "#{Rails.root}/x/x/files/offer_letter_sample.docx", "Receipt.docx"

Here is the resulting MessageBuilder object where the original_filename seems to be overwritten by the filename from the io or local_path instead of using the Receipt.docx name given

:attachment=>
 [#<UploadIO:0x0000000115bf5250
@content_type=
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
@io=
 #<File:/Users/x/x/x/x/x/x/files/offer_letter_sample.docx>,
@local_path=
"/Users/x/x/x/x/x/x/files/offer_letter_sample.docx",
@opts={},
@original_filename="offer_letter_sample.docx">,

Not sure if this is related to the fix in https://github.com/mailgun/mailgun-ruby/releases/tag/v1.3.3

Let me know if theres anything else I can do to help

matthewgani avatar Mar 27 '25 08:03 matthewgani

I would add that the Rails ActionMailer integration should also be considered as mails with attachments don't seem to set the name properly either.

victorbstan avatar Mar 28 '25 00:03 victorbstan

@matthewgani the issue is fixed in https://github.com/mailgun/mailgun-ruby/releases/tag/v1.3.5 Please check if it works for you. Thanks.

alex-leb avatar Apr 07 '25 17:04 alex-leb

@tttffff Thank you for the fix! @alex-leb it works as expected now, thanks!

matthewgani avatar Apr 15 '25 09:04 matthewgani