fphilipe / premailer-rails

CSS styled emails without the hassle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for alternative parts other than text/plain and text/html

md5 opened this issue · comments

We have an application that sends out emails with the following structure:

  • multipart/alternative
    • text/html
    • text/calendar

This mimics the style of emails sent out by Outlook, allowing invitation emails to be sent (and canceled) from a Rails application with native Outlook "Approve/Tentative/Decline" buttons.

I wanted to use premailer-rails to allow us to easily style these emails, but unfortunately it munges this email and drops the text/calendar part when it adds the text/plain part. I think I could probably get it to work by disabling the generation of the text/plain part, but I ended up falling back to inline styles and removing premailer-rails for the moment.

It would also be good to deal with messages that are structured similar to how Google Calendar structures its invitation emails:

  • multipart/mixed
    • multipart/alternative
      • text/plain
      • text/html
      • text/calendar
    • application/ics

Thanks for your input. Indeed, premailer-rails is a bit naive about this, judging by a quick look at the code. I think it simply grabs the text/html part and replaces it by a multipart/alternative that contains a text/html and a text/plain part.

This would be great for another reason as well: if you don't want to rely on premailer to generate the text/plain portion, there is no way to do this. Premailer clobbers whatever plaintext you may have created in ActionMailer.

PRs welcome ❤️