Sending HTML mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post 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
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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";
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post 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
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

care to post the current version of your code?
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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);
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Hi feyd,

Hmmm, still not working...
Post Reply