lbh2011 Posted January 28, 2012 Share Posted January 28, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/255956-apply-css-style-in-php/ Share on other sites More sharing options...
joel24 Posted January 29, 2012 Share Posted January 29, 2012 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> "; Quote Link to comment https://forums.phpfreaks.com/topic/255956-apply-css-style-in-php/#findComment-1312106 Share on other sites More sharing options...
ocpaul20 Posted January 30, 2012 Share Posted January 30, 2012 Display it on the screen, then when it works, stick it into the email. If that does not work, then it must be the way you are sending/composing the email itself. Quote Link to comment https://forums.phpfreaks.com/topic/255956-apply-css-style-in-php/#findComment-1312516 Share on other sites More sharing options...
joel24 Posted January 31, 2012 Share Posted January 31, 2012 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() Quote Link to comment https://forums.phpfreaks.com/topic/255956-apply-css-style-in-php/#findComment-1312885 Share on other sites More sharing options...
lbh2011 Posted January 31, 2012 Author Share Posted January 31, 2012 Thanks for the advice everyone! Problem solved. Quote Link to comment https://forums.phpfreaks.com/topic/255956-apply-css-style-in-php/#findComment-1312972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.