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
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>
";

Link to comment
Share on other sites

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 <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

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

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.