I'm trying to add an email confirmation function into a existing php script

[font=verdana]I’m trying to get my php form to send a simple email message to the persons email that submitted the form. Something like “Thanks we received your info”. I don’t know how to integrate that into my existing script. Below are the configurable parts of the php. The form works perfectly … just want to add the email confirmation function. Thanks!
_________________________________________________ [/font]_________________________________________________ _____

<?php $d = date("m-d-y H:i:s"); /* ************* Begin Configuration ************* */ $relocate = "http://www.xxxxx.com/"; // insert your relocation url here $home = "http://www.xxxxx.com/"; $MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/'; $PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/'; $sender_name = "Order"; $sender_email = "[email protected]"; $mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP"; //$to = "[email protected]"; $to = "[email protected]"; $subject = "Order"; $success_block = "

Thank you for submitting your information. We will review your information and get back to you within a day or two.



"; /* ************* End Configuration ************* */ // mail if ($send != "false") { mail($to, $subject, $msg, $mailheaders); // mail sent to admin header("Location: $relocate"); } ?>

Just add another mail() function call below first. Like this:
[php]// mail
if ($send != “false”) {
mail($to, $subject, $msg, $mailheaders); // mail sent to admin
mail($sender_email, $subject, ‘Thanks we received your info’); // confirmation email
header(“Location: $relocate”);
}
?>[/php]

You can add headers parameter as well, just use your (admin’s) email as a From: and Reply-To: within that header.

Thanks, but it didn’t work … I pasted your code below the existing //mail at the bottom of the page, and got an “Thanks We Received Your Info” email, (in addition the the form results email), but the FROM ADDRESS was not the email address entered into the form (it was [email protected])

I need to know how to amend the code … to send an email … to the email address entered into the form.

On my form the email is $Email = $_POST[“Email”]; and the lower part is $msg .= “Email: $Email\n”;

I don’t know how to add header parameters … if I use $_POST[“Email”] or $[font=verdana][size=11px]Reply-To: or From[/size][/font]
[font=verdana][/size][/font]
[font=verdana, sans-serif][/size][size=11px]Thanks[/size][size=11px][/font]

If field name in your form is named ‘Email’, you need to use this in the mail function (we can not guess what your form field names are):

[php]mail($_POST[‘Email’], $subject, ‘Thanks we received your info’);[/php]

Woo Hoo it worked! You are AWESOME!

The only thing now … is that I’m getting 2 emails letting me know that the form has been submitted (I only need one) … and the email that is sent to the user is showing technical mail server info … instead of my email address. How do I adjust that? And I suppose removing the upper mail header would keep it from sending me 2 emails?

This is what the FROM field looks like in the email that is sent to the user. It’s not my actual email address.


FROM: [email protected]

If you’re receiving 2 emails instead of one - probably you need to remove that second mail() function call that was added previously.
As for adjusting From: field in the email confirmation to user, you need to set headers parameter (similar to how this is done in your code above for email notification to admin. Here is the complete code:

[php]$my_email = ‘[email protected]’;
$mailheaders2 = “Content-Type: text/plain; charset=us-ascii\nFrom: Website Name <$my_email>\nReply-To: <$my_email>\nReturn-Path: <$my_email>\nX-Mailer: PHP”;

if ($send != “false”) {
mail($to, $subject, $msg, $mailheaders); // mail sent to admin
mail($_POST[‘Email’], $subject, ‘Thanks we received your info’,$mailheaders2); // confirmation email
header(“Location: $relocate”);
}[/php]

It took a few attempts, but it’s perfect now.

Now I have a much better understanding of how mail Headers work … just couldn’t get my head around it before.

Thanks You For Your Time & Effort!

Sponsor our Newsletter | Privacy Policy | Terms of Service