Mail Gem: Render received email in browser / Full parse of html parts

1.1k Views Asked by At

I am working with the Mail Gem to receive emails in my Rails 4 application. The mails are grabbed via POP from a mailbox, every 10 minutes or so, via the Gem.

I need to render these emails - mostly in HTML format - and am having trouble saving the body in HTML, not to mention working with things like embedded images. I'm probably missing something here- looked all over StackOverflow but haven't seen an answer to related questions yet.

I have been working with

message.body.decoded

and also looked at the html_part v. text_part - but I don't see a method to get to just the enclosed HTML. Looks like I need to strip the headers, which the Mail Gem seems to leave in the body- then also deal with any inline attachments. Surely a gem for this must exist..? Or an approach...? Your advice is valued.

I did find the Mailcatcher Gem - but that is really its own Sinatra app. I might just try adapting this gem but that appears to be a lot of work. Surely someone else has already dealt with this problem..?

I would also value a suggestion on how to best store the message body in MySQL - am thinking large text or blob type.

Thank you!

1

There are 1 best solutions below

0
On

I use letter opener It works fine... And if you are using vagrant as the main development machine you you can use this Letter opener web