View Full Version : Web Email Template

02-13-2003, 04:57 AM
I am emailing a thank you page to customers after they sign up. I have the signup page done and I also have an html version and a text version of the email setup. I would like to know if anyone knows any good sites or could help me in making the html page which is written in PHP and has variables to fill in a template and to email it using the mail() function. Thank you.

02-13-2003, 01:26 PM
I don't know any sites but I know how you can.

What you need to do is set it as a multipart message. I took the example below from another thread in this forum that I saved ages ago.

function send_multipart_mail($from, $to, $subject, $part1, $part2)
// the parts must be separated by the $separator string
// you can choose it anyway you like and when you
// use it, it has to start with -- (2 hyphens)

$separator = '__00';

// just 20 random characters

for ($i=0; $i<20; $i++) {
$separator .= chr(rand(ord('A'),ord('z')));

$header = "From:$from\n";
$header .= "Reply-To: ".$from."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: Multipart/alternative; boundary=\"$separator\"\r\n";
$header .= "Content-Disposition: inline;\r\n";

// the first part is just sthe text version that is passed to the function as $part1
$message = "\n\n--$separator\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 8bit\r\n";
$message .= "$part1\n";

//$message .= "Content-Disposition: inline;\n\n";
// the second part is the html version passed to the function as $part2
$message .= "\n--$separator\r\n";
$message .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$message .= "Content-Transfer-Encoding: 8bit\r\n";
$message .= "Content-Disposition: inline;\n\n";
$message .= "$part2\n";

// the last separator begin and ends(!) with --
$message .= "--$separator"."--\n";

return mail ($to, $subject, $message, $header);

echo "test for multipart emails<br>";
$to = "01matthew.wilson@ashdown.poole.sch.uk";
$from = "yoyur@emaosmart.com";
$subject = "finaly multipart emails ";
$part1 = "this is bold text right here on part 1 text version!";
$part2 = "<img src=\"$itf\" /><br /><br /><font face=\"verdana\" size=\"5\"><br><i>this</i> is <b>bold</b> <a href=#>text</a> right here on part 2!</font>";

if(send_multipart_mail($from, $to, $subject, $part1, $part2))
echo "email was accepted for dilivery";
echo "email was not accepted for dilivery";