Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Set correct content type when attaching files #17

Merged
merged 1 commit into from

2 participants

@cwsaylor

When files are attached the content type gets reset back to multipart/alternative. It should be multipart/mixed. This causes only the attachment to be displayed on certain email clients like the iPhone.

@ndbroadbent ndbroadbent merged commit 5ba6576 into premailer:master
@ndbroadbent
Owner

Thanks! I've released 1.5.3 with your change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2013
  1. @cwsaylor
This page is out of date. Refresh to see the latest.
View
2  lib/action_mailer/inline_css_hook.rb
@@ -34,6 +34,8 @@ def self.delivering_email(message)
body premailer.to_inline_css
end
+ message.content_type 'multipart/mixed' if ! existing_attachments.empty?
+
existing_attachments.each {|a| message.body << a }
end
View
11 test/inline_css_hook_test.rb
@@ -129,4 +129,15 @@ def test_preservation_of_attachments
assert_equal original_hello_attachment_url, mail.attachments["hello"].url
end
+ def test_alternative_content_type
+ mail = HelperMailer.use_inline_css_hook_with_text_and_html_parts.deliver
+ assert_match /multipart\/alternative/, mail.content_type
+ end
+
+ def test_mixed_content_type
+ File.stubs(:read).returns("world")
+ mail = HelperMailer.with_attachment
+ m = ActionMailer::InlineCssHook.delivering_email(mail.deliver)
+ assert_equal "multipart/mixed", m.content_type
+ end
end
Something went wrong with that request. Please try again.