PHP form > How to >
Sending an autoresponder message
Sending an autoresponder message
Want to send an autoresponder message to the person who
submitted your form? Maybe you want to just send a confirmation that you
received his/her message, maybe some further instructions, doesn't matter.
To send the autoresponder message you obviously need to know the e-mail address
of the person submitting the form, so make sure you have a "Your E-mail:"
input field in your form! If you are not sure how, go through our PHP forms tutorial first.
Let's say you have the e-mail address stored in $email variable (just like the
final form in my tutorial). Now you can send the
autoresponder message the same way you would send an e-mail to yourself, just
to a different address:
mail($email, "Thank you for your e-mail!",
"Hi, we received your message and will respond within 24 hours!");
|
Of course you can prepare the message and subject in variables
for clearer code. Again, using the final form code
we could set it up like:
/* Prepare autoresponder subject */
$respond_subject = "Thank you for contacting us!";
/* Prepare autoresponder message */
$respond_message = "Hello!
Thank you for contacting us! We will get back to you
as soon as possible!
Yours sincerely,
Your name
www.yourwebsite.com
";
/* Send the message using mail() function */
mail($email, $respond_subject, $respond_message);
|
So, to send an autoresponder message use the PHP mail() function
twice inside the code - once to send form result to yourself and the second
time to send an autoresponder message to the person who submitted
your form.
» Copyright notice
© 2008-2024 myPHPform.com. All rights reserved. Copying or redistributing
any part of this website without our written permission is expressly
forbidden!
|