Send Html Email Using Php Deliver Message As Html Code
iam sending html message contains table when i recive message on gmail,hotmail,yahoo account it works fine but when receiving on other client ie Microsoft outlook it resolve it as
Solution 1:
I Always use this function ,and it helps
function sendHTMLemail($HTML,$from,$to,$subject,$fromname)
{
$headers="From: ".$fromname." <".$from.">\r\n";
$headers.="Reply-To: ".$fromname." <".$from.">\r\n";
$headers.="MIME-Version: 1.0\r\n";
$boundary= uniqid("HTMLEMAIL");
// First we be nice and send a non-html version of our email $headers.="Content-Type: multipart/alternative;".
"boundary = $boundary\r\n\r\n";
$headers.="This is a MIME encoded message.\r\n\r\n";
$headers.="--$boundary\r\n".
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers.= chunk_split(base64_encode(strip_tags($HTML)));
// Now we attach the HTML version$headers.="--$boundary\r\n".
"Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers.= chunk_split(base64_encode($HTML));
// And then send the email ....
mail($to,$subject,"",$headers);
}
Solution 2:
I know this isn't an answer for your question, but I suggest using a mailing library, that will allow you to send mails much more easily, and supports features such as attachments, authentication, etc. I recommend SwiftMailer which works great, is simple and well documented.
Post a Comment for "Send Html Email Using Php Deliver Message As Html Code"