OK let recap what we have done so far in this PHP tutorial, we got the information from the format Step 1.

in Step 2. we validated the details using PHP and JavaScript

and now we are going to send the email to one.

here is what you are going to add to the part in the last part to send the message using PHP after validation inside the if that you have to fill this code in there:

$header='From: admin@yoursite.com' . "\r\n" .
'Reply-To: admin@yoursite.com' . "\r\n";

mail($email, $subject, $message, $header);

/*look at the description at the bottom of the code bellow for more information and explainations.*/

If you have used the JavaScript solution for validating the form details then you have to make this file:

File name is mail.php and this is the code:






$header='From: admin@yoursite.com' . "\r\n" .
'Reply-To: admin@yoursite.com' . "\r\n";

mail($email, $subject, $message, $header);

/*the code above will send an email from admin@yoursite.com to the $email address

if you want to send it from another email address you can add a field to the form so user can enter their email address and you can use it and for validation just copy the validation for email and change the email to clientemail or anything that you call that field.



Now that we sent the message to one, how can we send it to multiple recipients without re-entering the same data over and over? look at Step 4 to find out.
%d bloggers like this: