Skip to content
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

Handle Message With Empty Multipart Content #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions lib/sendgrid_actionmailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def to_attachment(part)
a.disposition = disposition unless disposition.nil?

has_content_id = part.header && part.has_content_id?
a.content_id = part.header['content_id'].value if has_content_id
a.content_id = part.header['content_id'].value.gsub(/\<|\>/, '') if has_content_id
end
end

Expand All @@ -126,8 +126,10 @@ def add_content(sendgrid_mail, mail)
when 'text/html'
sendgrid_mail.add_content(to_content(:html, mail.body.decoded))
when 'multipart/alternative', 'multipart/mixed', 'multipart/related'
sendgrid_mail.add_content(to_content(:plain, mail.text_part.decoded)) if mail.text_part
sendgrid_mail.add_content(to_content(:html, mail.html_part.decoded)) if mail.html_part
sendgrid_mail.add_content(to_content(:plain, mail.text_part.decoded)) if
mail.text_part and mail.text_part.body.present?
sendgrid_mail.add_content(to_content(:html, mail.html_part.decoded)) if
mail.html_part and mail.html_part.body.present?

mail.attachments.each do |part|
sendgrid_mail.add_attachment(to_attachment(part))
Expand Down