How to email in CSS (HTML)?

I’ve been looking at:

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\\r\
";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
";
//$headers .= 'Content-type: text/css; charset=iso-8859-1' . "\\r\
";
$headers .= 'Content-type: text/css;' . "\\r\
";

I want to use css, if possible in my newsletters to email. But I can’t find any info on this.

… use a standard <style></style> tag to define the CSS like you would in any normal HTML file, and then send the mail as type html…

If you are learning how to send HTML emails from PHP, then I would recommend to study some articles like:

http://www.programmersheaven.com/mb/phpstuff/345050/345050/attach-css-code-while-sending-email/

Otherwise, for professional purpose, it is really better to use PHPMailer to send any kinds of emails. You don’t have to do anything yourself. Just prepare your HTML and send it through PHPMailer class.

Download:
http://phpmailer.worxware.com/index.php?pg=sf&p=dl

Examples:
http://phpmailer.worxware.com/index.php?pg=examples

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
";

=

$headers .= "Content-type: text/html;\\r\
Charset=iso-8859-1\\r\
";

Strip out the unnecessary To: header (That’s handled by your $to variable)

Try that, see if that fixes it…

Oh And how does that work? <style></style> How do I put font, bold, size…

Hi
Below is the sample code.


<?php 
// multiple recipients
$to = 'test@sitepoint.com';

// subject
$subject = 'Testing';

//you can also include the source of the css file but must place the full URL with domain
//for example "http://sitepoint.com/test.css"
$css.='<style type="text/css">
		.test{
			font-size:12px;
			color:red;
		}
		</style>';
// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
  '.$css.'
</head>
<body>
  <p  class="test">Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th  class="test">Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\\r\
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
";

// Additional headers
$headers .= 'To: Mary <test@sitepoint.com>' . "\\r\
";
$headers .= 'From: Sitepoint <sitepoint@sitepoint.com>' . "\\r\
";

// Mail it
mail($to, $subject, $message, $headers);
?>

http://www.w3schools.com/TAGS/tag_style.asp

That’s the css <style> tag. What do you want me not to use inline?

$headers  = 'MIME-Version: 1.0' . "\\r\
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
";

Try it out for yourself
http://www.gbgrafix.com/thewheelofgod/twotexts/emailex.php
Yahoo seems more tolerant than hotmail. But it’s annoying that it goes in the junk folder. How does Sitepoint do it that the notifications go to the inbox?