Page 1 of 2

Posted: Wed Jul 14, 2004 6:28 pm
by lostboy
why doesn't anybody google any mroe?

Code: Select all

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

Posted: Wed Jul 14, 2004 6:30 pm
by feyd
mail() wrote:

Code: Select all

<?php
/* recipients */
$to  = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";

/* subject */
$subject = "Birthday Reminders for August";

/* message */
$message = '
<html>
<head>
 <title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
 <tr>
  <th>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, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";                                // <-------- HERE

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

/* and now mail it */
mail($to, $subject, $message, $headers);
?>

Posted: Wed Jul 14, 2004 6:30 pm
by mjseaden
lostboy - I would Google, but that's a pretty general search ('content-type headers')...

Posted: Wed Jul 14, 2004 6:30 pm
by mjseaden
Thanks lostboy and Feyd.

Posted: Wed Jul 14, 2004 7:21 pm
by patrikG
pickle wrote:I don't know about you, but I'm referring to server-based spam filters, such as Spam-Assasin, or Gee-Whiz. I know for a fact that an email consisting entirely of HTML gets an email flagged high as possible SPAM, although it doesn't guarantee. Client side spam filters might act differently though.
So am I. I am no expert on Spam-filters, but flagging an email as spam simply because its HTML would pretty much defeat the purpose of spam-filtering to my mind.

Posted: Thu Jul 15, 2004 2:52 am
by mjseaden
patrik,

I have to mention that as soon as I placed the HTML headers on my e-mails, my Hotmail automatically placed it in my junkmail inbox. If I don't place the HTML headers on there (still with HTML code), it still displays HTML but places it in my normal inbox. Strange though I agree.

Cheers

Mark

Posted: Thu Jul 15, 2004 5:29 am
by mjseaden
Okay,

I've implemented the headers, and Hotmail puts it into the junkmail folder.

However, for some reason the same problem is still occurring in Outlook Express, so I'm a little confused here. Could there be any other reason why Outlook isn't picking up the HTML?

Many thanks

Mark

Posted: Thu Jul 15, 2004 8:15 am
by lostboy
Make sure that you include all the headers. Hotmail is picky if it doesn't receive all the headers in the email

Code: Select all

$headers .= "MIME-Version: 1.0\n"; 
  $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; 
  $headers .= "X-Priority: 3\n"; 
  $headers .= "X-MSMail-Priority: Normal\n"; 
  $headers .= "X-Mailer: php\n"; 
  $headers .= "From: "".$myname."" <".$myemail.">\n";

Posted: Thu Jul 15, 2004 9:14 am
by pickle
patrikG wrote: So am I. I am no expert on Spam-filters, but flagging an email as spam simply because its HTML would pretty much defeat the purpose of spam-filtering to my mind.
I should clarify that an email consisting only of HTML will not get automatically flagged as SPAM because of that fact. Say, for example, an email needs a score of 4 to become SPAM. Spam filters will generally (although this is modifiable) give an email a score of 3 based on the HTML.

So, while it is possible to send an email only of HTML, you have to make sure your message is personal enough so that it won't get flagged.

Posted: Thu Jul 15, 2004 5:24 pm
by mjseaden
lostboy - thanks, your modified headers solved the Hotmail junk folders problem. However, the e-mail is still not being detected as HTML from Outlook Express. I've been told by a computer researcher friend of mine that Outlook seems to be a bit strange in this respect. Is there any way of solving this however? I have seen HTML e-mails work fine in Outlook, but mine doesn't seem to.

Cheers

Mark

Posted: Thu Jul 15, 2004 5:40 pm
by lostboy

Code: Select all

Mime-Version: 1.0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit    //<---- I just checked the properties on one i just got

Posted: Fri Jul 16, 2004 5:04 am
by mjseaden
Hi

I've tried implementing the header changes by putting in the Content-Transfer-Encoding information, however it's still not showing up as HTML in Outlook!

Bloomin' MS...

Mark

Posted: Fri Jul 16, 2004 5:10 am
by feyd
care to post the current version of your code?

Posted: Fri Jul 16, 2004 5:13 am
by mjseaden

Code: Select all

/* To send HTML mail, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";

/* additional headers */
$headers .= 'To: '.$name.' <'.$toadr.">\r\n";
$headers .= 'From: '.$row['Firstname'].' '.$row['Lastname'].' <'.$fromadr.">\r\n";
$headers .= "Cc: ".$cc."\r\n";
$headers .= "Bcc: ".$bcc."\r\n";

ini_set('sendmail_from', $fromadr );
mail($toadr,$subj,$message,$headers);
$message contains HTML code for the e-mail.

Cheers

Mark

Posted: Fri Jul 16, 2004 5:33 am
by feyd
Not entirely sure here, but try:

Code: Select all

/* To send HTML mail, you can set the Content-type header. */ 
$headers  = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "X-Priority: 3\r\n"; 
$headers .= "X-MSMail-Priority: Normal\r\n"; 
$headers .= "X-Mailer: php\r\n"; 
$headers .= "Content-Transfer-Encoding: 7bit\r\n"; 

/* additional headers */ 
$headers .= 'To: '.$name.' <'.$toadr.">\r\n"; 
$headers .= 'From: '.$row['Firstname'].' '.$row['Lastname'].' <'.$fromadr.">\r\n"; 
$headers .= "Cc: ".$cc."\r\n"; 
$headers .= "Bcc: ".$bcc."\r\n"; 

ini_set('sendmail_from', $fromadr ); 
mail($toadr,$subj,$message,$headers);