I have been trying to send a multipart text and html message through the mail() funciton. It works beautifully with Hotmail. However, when it is received by the IceWarp web-based mail server or by Outlook, some of the HTML is hacked out. Specifically, on href tags, look like this when viewing the source: <a href=ttp://.... It also chops off the last character of the url and the quote before the end ">" on the tag. I can't figure out what is happening
Any ideas?
Here is the code:
$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your text goes here
$message .= "Hello $friendname,\n\nI invite you to view a property on the RE/MAX Whatcom County website. The link shown below will take you directly to the property I would like you to see.\n\nhttp://www.homesinbellingham.net/property_launch.php?LN=$prop_num&table=$table\n\nSincerely,\n$username\n";
$message .= "\n";
// html section begins
$message .= "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html;\n charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your html goes here -- It didn't appear properly without
// the weird markup that outlook added after sending
$message .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
$message .= "<HTML><BODY>\n";
$message .= "Hello $friendname,<br><br>I invite you to view a property on the RE/MAX Whatcom County website. The link shown below will take you directly to the property I would like you to see.<br><br><a href=\"http://www.homesinbellingham.net/property_launch.php?LN%3d"."$prop_num"."&table%3d"."$table\">View the Property</a><br><br>Sincerely,<br>$username<br>";
$message .= "<hr>";
$message .= "</BODY></HTML>\n";
$message .= "\n";
// this ends the message part
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
//message ends
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "------=MIME_BOUNDRY_main_message--\n";
$headers = "From: $username<$usermail>\n";
$headers .= "Reply-To: <$usermail>\n";
$headers .= "MIME-Version: 1.0\n";
// the following is one line (post width too small)
$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n";
$headers .= "X-Sender: $username<$usermail>\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <$usermail>\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
mail ("$friendmail","See this listing on RE/MAX Whatcom County",$message,$headers);