php mail sending with html

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

Post Reply
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

php mail sending with html

Post by cjkeane »

Hi everyone,
I'm trying to send html emails but the emails are always received with the actual html tags, not displaying the html properly. I receive html emails from lots of companies, but when I try to send an email from an html form i created with php mail, I never receive the email correctly. I'm not sure what else to try. Any help would be appreciated. Thanks.

in the html of the page I have:

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


in the php mail part I have this set:

Code: Select all

        $semi_rand = md5(time());
 	$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
	$headers .= "MIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
	$message ="--{$mime_boundary}\n";
	$headers .= "Content-Type: text/html; charset=utf8\r\n";
	$message.="Content-Transfer-Encoding: 8bit\n\n";
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php mail sending with html

Post by Christopher »

Use SwiftMailer, PhpMailer, etc. MIME emails are tedious to get right.
(#10850)
Post Reply