4
5
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
|
# File 'lib/premailer/rails/hook.rb', line 4
def self.delivering_email(message)
if message.html_part
html_body = message.html_part.body.to_s
needs_multipart = true
message.parts.delete(message.html_part)
elsif message.content_type =~ /text\/html/
html_body = message.body.to_s
message.body = nil
needs_multipart = Rails.config[:generate_text_part]
end
if html_body
premailer = CustomizedPremailer.new(html_body)
charset = message.charset
if needs_multipart
if Rails.config[:generate_text_part] \
and not message.text_part
message.text_part do
content_type "text/plain; charset=#{charset}"
body premailer.to_plain_text
end
end
message.html_part do
content_type "text/html; charset=#{charset}"
body premailer.to_inline_css
end
else
message.body = premailer.to_inline_css
end
end
end
|