/    Sign up×
Community /Pin to ProfileBookmark

I need an autoreply email when a user submits my forms

Hi,

As the above states I need an autoreply email to send to my customers when they submit a form.

I have a normal html form – example [url]http://www.needtaxiquote.co.uk/article.php?aid=29[/url] with a submit button that sends the form results to my email. I know how to set up an autoreply in Outlook/Express but the response would direct to the server as I have php details server side.

How do I get the autoreply to send to the user’s email? What alternatives are there?

Thanks

Sam

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@TaboJan 22.2007 — You need php not html, its serverside, does your server have php?

You need the var of the email field, lets call it $email

[CODE]<form method="post" action="whatever.php">[/CODE]

whatever.php:

[CODE]::Your content here::

<script language="php">$email = $HTTP_POST_VARS[email];

$mailto = "$email";

$mailsubj = "Reply to your form sub...";

$mailhead = "From: $emailn";

reset ($HTTP_POST_VARS);

$mailbody = "Values submitted from web site form:n";

while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $valn"; }

if (!eregi("n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

</script>

[/CODE]
Copy linkTweet thisAlerts:
@mastrebligauthorJan 22.2007 — Sorry, didn't explain myself too well - I do have PHP server side.

How do I weave what I just told you into the code below?

Cheers


<?PHP

#######################################################

# This script is Copyright 2003, Infinity Web Design #


# Distributed by http://www.webdevfaqs.com #


# Written by Ryan Brill - [email][email protected][/email] #


# All Rights Reserved - Do not remove this notice #


#######################################################

## The lines below need to be edited...



###################### Set up the following variables ######################

#


$to = "[email protected]"; #set address to send form to

$subject = "Taxi Insurance Enquiry"; #set the subject line

$headers = "From: Taxi Driver"; #set the from address, or any other headers

$forward = 0; # redirect? 1 : yes || 0 : no

$location = "thankyou.htm"; #set page to redirect to, if 1 is above

#


##################### No need to edit below this line ######################

## set up the time ##



$date = date ("l, F jS, Y");

$time = date ("h:i A");

## mail the message ##



$msg = "Below is the result of your feedback form. It was submitted on $date at $time.nn";

if ($_SERVER['REQUEST_METHOD'] == "POST") {

foreach ($_
POST as $key => $value) {

$msg .= ucfirst ($key) ." : ". $value . "n";

}

}

else {

foreach ($_GET as $key => $value) {

$msg .= ucfirst ($key) ." : ". $value . "n";

}

}

mail($to, $subject, $msg, $headers);

if ($forward == 1) {

header ("Location:$location");

}

else {

echo "Thank you for submitting the form. Our specialist taxi department will get back to you as soon as possible.";

}

?>
Copy linkTweet thisAlerts:
@mastrebligauthorJan 22.2007 — Test

(Posted 2 replies, nothing coming up)
Copy linkTweet thisAlerts:
@TaboJan 22.2007 — Ok, add this below the other script

&lt;script language="php"&gt;$email = $HTTP_POST_VARS[email];

$mailto = "$email";

$mailsubj = "Reply to your form sub...";

$mailhead = "From: $emailn";

reset ($HTTP_POST_VARS);

$mailbody = "Values submitted from web site form:n";

while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $valn"; }

if (!eregi("n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

&lt;/script&gt;



Lets say the id or what ever it is of your form field that the user enters their email is called email, so the var will be $email. This will email the form results to their email address plus the text "Values submitted from web site form:"
Copy linkTweet thisAlerts:
@TaschenJan 22.2007 — A word of warning: you are laying your server wide open to spammers.

It wouldn't take long to write a script external to your server that takes advantage of the above unsecured mail() routine.

Rather than sending a confirmation on submit:

First check where the request is coming from, your server or not (but don't rely on IP address as this is very easy to spoof, set a time limited token) -> next check that you have a genuine email address -> then whether the address is actively used by the person supposedly submitting the form (send an email with a hardcoded message body (ie not held in a variable) requesting a response -> if a response is received then send your confirmation.

What ever you do do please don't simply fire off an email to an unverified address, it's spammer heaven.
Copy linkTweet thisAlerts:
@mastrebligauthorJan 23.2007 — Lets say the id or what ever it is of your form field that the user enters their email is called email, so the var will be $email. This will email the form results to their email address plus the text "Values submitted from web site form:" [/QUOTE]

I don't want to send them the form results though... I want to send the form user an image (basically a form with a phone number and thankyou note etc.) in the form of a jpeg.
Copy linkTweet thisAlerts:
@TaboJan 23.2007 — Well then change the PHP

Values submitted from web site form:
with your code and get rid of the rest
×

Success!

Help @mastreblig spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...