css and ActionMailer

Hello!

I've been trying to send html with css emails with ActionMailer, the
html part goes perfect, but the css doesn't seem to work.
I have tried using
<link href="http://url/stylesheets/layout.css" rel="stylesheet"
type="text/css" />

and also embeding it in the html, like this:
<style type="text/css">
body {
....
}
</style>

but none of those ways seems to work :cry:

Any ideas?

I'm using Rails 2.0.2

Thx in advance

Most email clients block links to external stylesheets. So your
embedding version should work. I use this all the time so I'm not
certain where you're getting blocked. Have you tested it across
multiple email clients? What does the raw email body look like? As you
expect or is the css getting pared out?

Have you tested it across multiple email clients?

I’m sending the email to my gmail account (this one) and it doesn’t render the css.
Now that you mention it I’m trying to watch it through thunderbird (using POP in my gmail account) and the embeded version works nicely. Any guess why gmail doesnt show the mail correctly?

What does the raw email body look like? As you
expect or is the css getting pared out?

Yes, there are no characters scaped or something strange in the mail, at least, nothing that i noticed.

Here is a paste of the “Show Original” from gmail:

I've been trying to send html with css emails with ActionMailer, the
html part goes perfect, but the css doesn't seem to work.
I have tried using
<link href="http://url/stylesheets/layout.css" rel="stylesheet"

/

and also embeding it in the html,

/

but none of those ways seems to work :cry:

In my experience, inline CSS gives the best results across a variety
of email clients.

FWIW,

Gmail isn't going to let you do something dangerous like that, lol.
They don't even let you see external images without saying yes first
:slight_smile:

Gmail isn't going to let you do something dangerous like that, lol.

Are you suggesting that "inline CSS" is dangerous?? How so?

In any case, I can assure you that the HTML emails I do for clients
render just fine in Gmail :slight_smile:

If one has to have HMTL/CSS emails, go "1996" HTML. Use tables for
layout. That sort of thing.

Now I haven't used this service but I saw it a while ago.
http://www.mailchimp.com/add-ons/inboxinspector/
"MailChimp Inbox Inspector - Check your email marketing campaigns with
one easy click"
It renders your email in different clients so you can see how they
look.

HTH
John

I'm facing the same problem: sending an HTML mail formatted with an
internal stylesheet be will displayed unformatted in some mail clients,
i.e. GMail:
<style type="text/css">
<!--
h1{color: red;}
-->
<h1>Hello</h1>

Instead, you have to use inline style (inside an HTML element):
<h1 style="color: red;">Hello</h1>

Hi,

I have a scenario where in my system is generating the mail and it is
being sent via my gmail acc and it has an attachment as well with
predefined text and all. But when the same mail is sent from the
clients system, then in my attachment the disclaimer of the client
company is coming in.
Why is this happening. My emails should have the settings of my
account but why does the client settings chip in even when emails are
being sent out using my account.

Any thoughts on this.

Neha