Page 1 of 1

Help with the mail() function please...

Posted: Tue Dec 12, 2006 10:56 pm
by jdhorton77
Ok, I've got a user registration page, now when all the validation is completed I want to email the user and have him click on a link to another page where they will enter in a code to complete the registration.

My question is, for the message parameter can I use an HTML page?
i.e.

Code: Select all

mail($eAddress,$subjectString,Message.html);

Posted: Tue Dec 12, 2006 11:00 pm
by feyd
Yes, you can.

Posted: Tue Dec 12, 2006 11:08 pm
by Sloth
You'd have to set the headers of the mail tho, otherwise you might end up with just a heckuva lot of html tags that's not very readable

Posted: Wed Dec 13, 2006 12:23 am
by jdhorton77
ok, so what do you mean by set the headers?

Posted: Fri Dec 15, 2006 3:03 am
by sh33p1985
you have to set the optional headers variable of the mail() function to verify the content type of the mail as HTML:

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

then use mail($to, $subject, $message, $headers);