Rails convert an html email to a text email
Given an html email message, is there a way to convert that to a text version? I'm doing email ingestion and notice that some times an email doesn't include a text version, especially with blackberry devices.
Perhaps I'm missing something, but couldn't you just take the HTML message and run ActionView::Helpers::SanitizeHelper#strip_tags over it?
HTML to Text is one of the features provided by the Premailer gem.
premailer = Premailer.new('http://example.com/html_email.html') premailer.to_plain_text
In case you don't want to use it because it does a lot, you can look at the code for how it does it here
I know this post is old, but it comes up high in Google for "convert html to text". The following may meet your needs:
The author says:
Ruby convert HTML to formatted text — Chip’s Tips for Developers. When you want to have your whitespace and feed it, too.
Refer the following link http://edgeguides.rubyonrails.org/action_mailer_basics.html
Action mailer provides options for sending a html or text emails.......