How to send HTML email with styles in rails

I want to know how we can send a webpage (HTML page) as an email. I want to add style to html page like images or table formatting. I want to know what should I add styling to my "conta.text.html.erb" or can I add CSS to it?

+2


a source to share


3 answers


This is not the best way to add your CSS file to an email. You need to define your CSS inline in your email.



About Asset, it's best to post it on your website. You can link it by email. Your email is easier with this technique.

+5


a source


Some element I found in multi-client email readability:

Using tables to arrange layouts and elements

Don't include images directly in your email address, but link to them from your site src = " http://example.com/myimage.jpg "



Always submit a text backup if your end user's client cannot read the html (e.g. military).

Use inline styles as recommended by sihingara, if you must require css and / j make sure you enter an absolute path, so src = " http://example.com/myjavascript.js " instead of src = "/myjavascript.js"

Hope this helps if not ask for a follow-up comment.

+1


a source


As mentioned above, HTML emails don't pair well with style blocks that are declared out of order. Webmail clients, in particular, tend to exclude them entirely.

The best practice is to use inline styles only; for this I highly recommend the Premailer Plus gem which will embed all the styles in the html block. Depending on your workflow; you can do this when you create templates or as a pre-processor before sending each message.

0


a source







All Articles