Languages :: PHP :: php mail() disaster |
|||
| By: FlorenceYee |
Date: 29/06/2003 00:00:00 |
Points: 300 | Status: Answered Quality : Excellent |
|
I'm new to PHP so please help me: <? $myboundary = "_Boundary--_". md5(rand()) .""; $headers .= "Content-Type: multipart/alternative; boundary=\"$myboundary\"\n"; $headers .= "From: webmaster@myweb.com\n"; $headers .= "Date: " . date("r") . "\n"; $headers .= "--$myboundary\n"; $headers .= "Content-Type: text/html; charset=\"utf-8\"\n"; $headers .= "Content-Transfer-Encoding: quoted-printable\n"; if(mail($rcpt,$Subject,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n".stripslashes($myBody)."\n--$myboundary--",$headers)){ Header ("HTTP 302 Redirect"); Header ("Location: " . "<A HREF="http://myweb.com">http://myweb.com</a>"); }; ?> I couldn't even send good HTML messages without it getting crippled. Most " are turned into \" and sometimes even =" are thrown away. I've most problem with Iplanet messaging servers. they even replace the boundaries with their own. Help anyone! how do i preserve a pure HTML for my messages? |
|||
| By: ThG | Date: 29/06/2003 03:03:00 | Type : Assist |
|
I can't understand from only that code what exactly is going on, but i can give you two tips that will surely help: 1) before taking any parameter from $_GET or $_POST (or if you have register_globals ON, from the parameter variable) without passing it thru stripslashes(), and BEFORE using it for concatenating with some html tags.. 2) pass all the data you are inserting thru htmlentities(), again before concatenating with html tags. i hope this helps |
|||
| By: VGR | Date: 29/06/2003 04:45:00 | Type : Answer |
|
| 1) $headers .= "--$myboundary\n"; is wrong the boundary is in the BODY only in the headers, it should read like : $headers.="Content-Type: multipart/mixed; boundary=\"--$myboundary\"\r\n"; 2) don't forget ALSO that the OFFICIAL separator in headers is \r\n, NOT \n alone 3) don't forget also that you need a blank line before the body starts |
|||
| By: FlorenceYee | Date: 29/06/2003 16:13:00 | Type : Comment |
|
| another problem is i'm transfering $myBody from another website running ASP.Net. All the characters seemed to be HTML encoded when php mail() sends it out. Do i have to encode the HTML before POST or what? |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








