Jump to content

Apply CSS Style in PHP


lbh2011

Recommended Posts

Hello!

 

Quick question which I hope someone will be able to answer!

 

How do I apply this style

<style type="text/css">
.text {	font-family: Arial, Helvetica, sans-serif;
color: #666;
font-size: 12px;
font-weight: normal;
text-decoration: none;
margin-right: 15px;
}
</style>

to the code below, which will become text in an PHP generated HTML email

$message .= "Dear ".clean_string($Name).",\n\n";	
$message .= "Thank you for your message.\n\n"; 

 

I beleive I need to use a css span class but can't get it to work!

 

Thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/255956-apply-css-style-in-php/
Share on other sites

are your assigning the content-type to indicate a html email? read up mail function

 

$message = "<html> 
<head>
<style type='text/css'>
.text {	font-family: Arial, Helvetica, sans-serif;
color: #666;
font-size: 12px;
font-weight: normal;
text-decoration: none;
margin-right: 15px;
}
</style>
</head>
<body>
<span class='text'>Dear ".clean_string($Name).",<br/>
Thank you for your message.</span>
</body>
</html>
";

are you setting the email mime type headers? re: link in my last post

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

// Additional headers
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

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

 

if you're still having trouble, have a look at phpMailer()

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.