Skip to content
Browse files

Use mail's text_part and html_part methods to avoid rendering attachm…

…ents as plain text
  • Loading branch information...
1 parent 678a549 commit eb765416d491ea1bc8789b691282e3ee9d396e0f @davidcornu committed May 10, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/letter_opener/delivery_method.rb
View
4 lib/letter_opener/delivery_method.rb
@@ -6,7 +6,9 @@ def initialize(options = {})
def deliver!(mail)
location = File.join(@options[:location], "#{Time.now.to_i}_#{Digest::SHA1.hexdigest(mail.encoded)[0..6]}")
- messages = mail.parts.map { |part| Message.new(location, mail, part) }
+ messages = []
+ messages << Message.new(location, mail, mail.html_part) if mail.html_part
+ messages << Message.new(location, mail, mail.text_part) if mail.text_part
messages << Message.new(location, mail) if messages.empty?
messages.each { |message| message.render }
Launchy.open(URI.parse("file://#{messages.first.filepath}"))

0 comments on commit eb76541

Please sign in to comment.
Something went wrong with that request. Please try again.