Issue with HTML displayed in email sent from PHP -


i'm using pear php mail library send html emails (mainly hotmail). i'm having issues css functioning correctly. @ moment when message received css in body of message , styles not applied.

the code follows:

$message = "<!doctype html>  <html> <head> <style>         body {     font:12px/1.4em verdana, sans-serif;     color:#333;     background-color:#fff;     width:700px;     margin:50px auto;     padding:0; }  {     color:#326ea1;     text-decoration:underline;     padding:0 1px; }  a:hover {     background-color:#333;     color:#fff;     text-decoration:none; }  div.header {     border-bottom:1px solid #999; }  div.item {     padding:5px 0;     border-bottom:1px solid #999; }   </style> </head>     </body>";  // parse         $limit = 9;     for($x=0;$x<$limit;$x++) {         $title = str_replace(' & ', ' &amp; ', $news[$x]['title']);         $link = $news[$x]['link'];         $description = $news[$x]['desc'];         $date = date('d-m-y', strtotime($news[$x]['date']));         $message .= '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';         $message .= '<p>'.$description.'</p>';     }      $message .="</body> </html>";         foreach($email_add_arr $name => $email) {  $crlf = "\n"; $from = ""; $to = "$name <$email>"; $subject = "news - $date"; $host = "ssl://smtp.gmail.com"; $port = "465"; $username = ""; $password = "";  // creating mime message $mime = new mail_mime();  // setting body of email $mime->sethtmlbody($message); $body = $mime->get();     $headers = array ( 'from' => $from, 'to' => $to, 'subject' => $subject, 'mime-version: 1.0',                     'content-type: text/html; charset=iso-8859-1'); $smtp = mail::factory('smtp',                     array ('host' => $host,                      'port' => $port,                      'auth' => true,                      'username' => $username,                      'password' => $password                      ));  $mail = $smtp->send($to, $headers, $message);  if (pear::iserror($mail)) {     echo("<p>" . $mail->getmessage() . "</p>"); } else {     echo("<p>message sent!</p>");     } } 

anyone have experience this?

thanks!

you can apply inline styles in mails.

for example:

<div style="float:left; padding: 10px;">demo</div> 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -