2

I'm trying to have a css file be included in an email but I'm not really sure if that's possible.

What I've tried so far is to send a complete valid html markup within the message parameter and include the css as I normally would in a file but that didn't work. Apparently message is the body of the email.

So then I guess it must be sent within the headers parameter but I'm not really sure how exactly to have that set up?

Here're my headers

$headers = "From: $from\r\nReply-To: noreply@".strtolower(website_name);
$headers .= "\nMIME-Version: 1.0\nContent-Type: text/html; charset=\"utf-8\"\r\n

What would I need to put in order to include http://site.com/style.css as a valid style to apply in the email?

7
  • 1
    This might be helpful: stackoverflow.com/questions/2105963/… Commented Jun 24, 2013 at 18:39
  • in email template you should write the inline style Commented Jun 24, 2013 at 18:42
  • 1
    If you sent me an email that tried to fetch a CSS file, I'd consider it junk, and I'd assume you're trying to track if I read your email... Commented Jun 24, 2013 at 18:42
  • @JuanMendes How would you even know? :D Commented Jun 24, 2013 at 18:47
  • @php_nub_qq Most email clients have an option to ask to load external resources. It isn't very often that they are used outside of junk mail. Commented Jun 24, 2013 at 18:54

1 Answer 1

6

Linking to external css from an email is not a good idea. It can work, but most clients are going to block the external request. Embed the CSS in the HTML of the email itself.

Sign up to request clarification or add additional context in comments.

3 Comments

I got that, but just for the sake of understanding, how is it done?
You just include a <link rel='stylesheet' href='example.com/example.css' type='text/css' />
Probably because your client is not allowing it, which is why it is a bad idea in the first place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.