6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/action_mailer/inline_css_hook.rb', line 6
def self.delivering_email(message)
if html_part = (message.html_part || (message.content_type =~ /text\/html/ && message))
host = ActionMailerInlineCss.base_url || message.[:host].to_s
premailer = ::Premailer.new(html_part.body.to_s, :with_html_string => true, :base_url => host)
msg_charset = message.charset
if message.text_part && message.text_part.body.to_s
html_part.content_type "text/html; charset=#{msg_charset}"
html_part.body premailer.to_inline_css
else
existing_attachments = message.attachments
message.body = nil
message.text_part = Mail::Part.new do
content_type "text/plain; charset=#{msg_charset}"
body premailer.to_plain_text
end
message.html_part = Mail::Part.new do
content_type "text/html; charset=#{msg_charset}"
body premailer.to_inline_css
end
message.content_type 'multipart/mixed' if ! existing_attachments.empty?
existing_attachments.each {|a| message.body << a }
end
message
end
end
|