class HtmlLinksToTextInterceptor

An ActionMailer interceptor that converts HTML links to a text-representation in the text/plain part of emails.

Public Class Methods

delivering_email(message) click to toggle source
# File lib/html_links_to_text_interceptor.rb, line 40
def self.delivering_email(message)
  return message unless message.text_part

  text_body = message.text_part.body
  message.text_part.body = scrub_body(text_body).to_s
  message
end
previewing_email(message) click to toggle source
# File lib/html_links_to_text_interceptor.rb, line 48
def self.previewing_email(message)
  delivering_email(message)
end
scrub_body(body) click to toggle source
# File lib/html_links_to_text_interceptor.rb, line 52
def self.scrub_body(body)
  Loofah.fragment(body.to_s).scrub!(LinkScrubber.new)
end