Page 1 of 2
Sending HTML mail
Posted: Wed Jul 14, 2004 10:38 am
by mjseaden
Dear All,
I'm programming my sendmail form on my company website to send a standardised formatted e-mail with company logo and signature. However, some e-mail reading systems don't support HTML e-mails - is there any general rule to follow regarding sending HTML, or any way of detecting if the destination address can read HTML email (a longshot I know, but you never know).
Many thanks
Mark
Posted: Wed Jul 14, 2004 11:14 am
by lostboy
phpmailer is what you want...
Posted: Wed Jul 14, 2004 11:55 am
by pickle
Sending HTML mail is very dicey, as most anti-spam filters tag email consisting of only html very high. After that, it's very hard to not get tagged as SPAM. IMHO, I'd forget about the HTML email and just send a text email.
Posted: Wed Jul 14, 2004 12:09 pm
by patrikG
pickle wrote:Sending HTML mail is very dicey, as most anti-spam filters tag email consisting of only html very high. After that, it's very hard to not get tagged as SPAM. IMHO, I'd forget about the HTML email and just send a text email.
In my experience that's not the case and, thinking about it, spam-filter live from being as precise as can be when it comes to spam. Thus, filtering because of a content-type would make no sense.
In fact, even most private emails I receive are HTML.
Posted: Wed Jul 14, 2004 12:20 pm
by pickle
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.
Posted: Wed Jul 14, 2004 1:59 pm
by mjseaden
Hi
I've actually done the HTML mailing part myself customised. I've just send an e-mail with HTML code, with subject/body/company address text all taken from external variables and inserted into the message text.
My HTML e-mail works exactly as planned from my hotmail account, but when I look on Outlook, it comes up as text (just plain text HTML code) - despite the fact that it has <HTML></HTML> tags as required.
Any ideas?
Mark
Posted: Wed Jul 14, 2004 2:13 pm
by lostboy
might be malformed html headers in the code...hard to say without looking at the code you use to send the email...
Posted: Wed Jul 14, 2004 2:20 pm
by feyd
you probably need the content-type in the headers..
Posted: Wed Jul 14, 2004 6:23 pm
by mjseaden
feyd, can you clarify?
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