Help with the mail() function please...

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
User avatar
jdhorton77
Forum Commoner
Posts: 56
Joined: Tue Nov 07, 2006 3:29 pm
Location: Charlotte, NC

Help with the mail() function please...

Post 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);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yes, you can.
Sloth
Forum Newbie
Posts: 18
Joined: Thu Dec 07, 2006 7:29 pm

Post 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
User avatar
jdhorton77
Forum Commoner
Posts: 56
Joined: Tue Nov 07, 2006 3:29 pm
Location: Charlotte, NC

Post by jdhorton77 »

ok, so what do you mean by set the headers?
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

Post 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);
Post Reply