Skip to content

Commit

Permalink
Use mail's text_part and html_part methods to avoid rendering attachm…
Browse files Browse the repository at this point in the history
…ents as plain text
  • Loading branch information
davidcornu committed May 10, 2012
1 parent 678a549 commit eb76541
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/letter_opener/delivery_method.rb
Expand Up @@ -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}"))
Expand Down

0 comments on commit eb76541

Please sign in to comment.