Jump to content

i give up, how do you make confirmation emails


real_illusions

Recommended Posts

on sites such as play.com, amazon etc...when you submit an order, you get a copy of your order and stuff.now, i'm not planning on doing something that complicated (not yet anyway), but i simply want to send the user a confirmation email whenever they send an email to me.like "thanks you $name for your email. If you require a reply, we will get back to you soon"or whatever. important to have their name on the email. makes it more personal, rather than an automated machine like thing. i use http://formtoemail.com/ script, so if there is a way to update the script to include the confirmation email thingy, then it would make things alot easier in updating the page.:)

Link to comment
Share on other sites

Well it is quite simple really. When you are processing the form and setting it up to have it email to you, create another email object and set it up and send it to the user.I am not sure how it works in PHP, but it is as simple as I explained in .Net

Link to comment
Share on other sites

add a line after the $my_email line:

$user_email = "$_POST[\"Email\"]";

Then, in this section:

// This line prevents a blank form being sentwhile(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}$message = $message . "-- \nThank you for using FormToEmail from http://FormToEmail.com";$message = stripslashes($message);$subject = "FormToEmail Comments";$headers = "From: " . $_POST['Email'] . "\n" . "Return-Path: " . $_POST['Email'] . "\n" . "Reply-To: " . $_POST['Email'] . "\n";mail($my_email,$subject,$message,$headers);

add:

$user_message = "Thank you $_POST[\"Name\"] for your email.  Whatever else you would like to tell them in the email.";$user_subject = "Subject of email you want sent to user";mail($user_email,$user_subject,$user_message);

Link to comment
Share on other sites

you could try taking out the " " in the $_POST part:

$user_email = $_POST[\"Email\"];

Or, look at lines BEFORE that. Often a parse errorr like you're getting is because of an extra (or missing) " BEFORE the line the error actually references. Check to make sure you don't have a missing quote somewhere.If you want, post your code up to that line and I'll see if I can find the error too.

Link to comment
Share on other sites

$my_email = "myemail@nowhere.co.uk";$user_email = "$_POST[\"Email\"]";is the first code lines. (except i replaced my email...not that i dont trust you guys, just evil spam bots). theres a load of comments above that code, but no code in the comments.taking the "'s out of the 2nd line where you said made no difference..except for a new error - Warning: Unexpected character in input: '\' (ASCII=92) state=1 in line 52foillowed byParse error: parse error, expecting `']'' in line 60and line 60 is$continue = "index.php";

Link to comment
Share on other sites

Sorry I forgot to mention that! The \ is an escape character for the quotes in the middle of a string. So, if you change the first line I told you to add, it needs to change to:$user_email = $_POST["Email"];Let me know if that works. Otherwise, actually seeing your code up to that point might still be helpful. (You could still change out your e-mail address :) but leave everything else the same)

Link to comment
Share on other sites

it all works except for the confirmation emaili changed this line to the following to get rid of a similiar error that happened with / thingy i presume.$user_message = "Thank you $name for your email. Whatever else you would like to tell them in the email.";but i dont see how that stops the confirmation email.i get all the field forms and whatever else sent with no problem, and the user is sent to the thank you page with no problem. just no confirmation email is sent.

Link to comment
Share on other sites

nevermind - reread your post and it makes sense now.Try adding the same headers to the second e-mail and see if that works...change

mail($user_email,$user_subject,$user_message);

to

mail($user_email,$user_subject,$user_message,$headers);

Link to comment
Share on other sites

still same problemhowever, i asked elsewhere and someone came up with this. this one is better in the sense that you can alter the email, and subject line that the user sees in their email. i receive both emails, however the one thats sent to 'me', as in the forms filled out, is blank. and i cant work out why. this is the original script he gave me, however i added more fields like the name, message etc fields to the form. but i didn't add any others anywhere, that maybe the problem. i'm not sure.so if we can come up with somethings that a mixture of both, i can alter the email and subject line that the user sees, and a copy of what they filled out in the form as well as me seeing the stuff i want to see in the email..that'd be great :)

<?php$to      = 'youremail@example.com';$subject = 'the subject';$replysubject = 'Email recived';$name = $_POST['name'];$email = $_POST['email'];$message = $_POST['message'];$headers = "From: $email" . "\r\n" .   "Reply-To: $email" . "\r\n" .   'X-Mailer: PHP/' . phpversion();$replyHeaders = "From: $to" . "\r\n" .   "Reply-To: $to" . "\r\n" .   'X-Mailer: PHP/' . phpversion();//Origonal messagemail($to, $subject, $message, $headers);//Return Message$reply = "Hello $name,Thankyou for your email, we will get back to you as soon as possible.Your Message was as follows:$message";mail($to, $replysubject, $reply, $headers);?>

Link to comment
Share on other sites

I beileve your Forms names might be different than what is in your $_POST command in that latest script. If I remember correctly, the message field in the form was named "Message", which would mean you need to use$_POST['Message'];instead of $_POST['message'];

Link to comment
Share on other sites

from one problem to another :( the emails now work. all the info goes to the correct person and is there in the email.however, the user, receives the email from themselves from the site. (tried it with another email account). so they can reply to themselves if they want. but its not exactly whats needed :)other than that, it seems to be going right at last...for now...till my computer blows up or something..or my head with all this code :)

Link to comment
Share on other sites

mail($user_email,$user_subject,$user_message,$user_headers);mail($to,$user_subject,$user_message,$replyheaders);mail($to,$user_subject,$user_message,$user_headers);all dont work at all.mail($user_email,$user_subject,$user_message,$headers);works but makes it so the user has received an email from themselves.and the very original you supplied doesn't send an email at all.and mail($to, $replysubject, $reply, $replyHeaders);sends an email but no original email or title. the title is "apache" and the email is the servers email thingy..which i dont want people to see..its kinda unofficial and not related to the sites name. :):(:)

Link to comment
Share on other sites

yeah..the title/subject is apache on that last suggestion of yours instead of "email" or "thank you" or something.and the original email..i perhaps worded that a bit wrong. the email as in where its coming from. instead of the email it goes to, which is what i would like to say where its from, instead of the users own email like it does on some of them.does that make any sense?

Link to comment
Share on other sites

yeah..the title/subject is apache on that last suggestion of yours instead of "email" or "thank you" or something.and the original email..i perhaps worded that a bit wrong. the email as in where its coming from. instead of the email it goes to, which is what i would like to say where its from, instead of the users own email like it does on some of them.does that make any sense?

Yes, that makes sense.I just realized that in the latest code segment you're going off of, the variables: $to, $subject, and $replysubject are all in single quotes --> ' 'Try changing those single quotes to double quotes --> " "See if that helps.
Link to comment
Share on other sites

there is no single or double quotes on the last line we keep changingi even tried adding in user headers and changing the order around on the last line, but that didn't make any diference. and swapping the single quotes for double quotes in the $headers lines.

$subject = "email";$headers = "From: " . $_POST['email'] . "\n" . "Return-Path: " . $_POST['email'] . "\n" . "Reply-To: " . $_POST['email'] . "\n";mail($my_email,$subject,$message,$headers);$user_message = "Thank you $name for your email.  Whatever else you would like to tell them in the email.";$user_subject = "Thank You";$user_headers = "From: " . $_POST['my_email'] . "\n" . "Return-Path: " . $_POST['my_email'] . "\n" . "Reply-To: " . $_POST['my_email'] . "\n";mail($user_email,$user_subject,$user_message,$user_headers);

logically, it should work..but yet it doesn't.i keep getting the server email instead of my email as the "from" on the user email, and no "reply to" either.

Link to comment
Share on other sites

there is no single or double quotes on the last line we keep changing
Not on the last line, on the first few lines - the variable declarations:
<?php$to      = 'youremail@example.com';$subject = 'the subject';$replysubject = 'Email recived';

Try changing those single quote to double quotes.

Link to comment
Share on other sites

you were on about the one i posted?!?i was on about formtoemail one:)either way..neither works.although the formtoemail one doesn't work better. its just the headers that are a problem with that one.the other one, whole host of problems, sent to the wrong email, stuff doesn't appear in the email i'm supposed to get etc etc..

Link to comment
Share on other sites

<?php$to      = "someone@somehost.com";$subject = "Submission";$replysubject = 'Email recived';$name = $_POST['name'];$email = $_POST['email'];$message = $_POST['message'];$headers = "From: $email" . "\r\n" .  "Reply-To: $email" . "\r\n" .  'X-Mailer: PHP/' . phpversion();$replyHeaders = "From: $to" . "\r\n" .  "Reply-To: $to" . "\r\n" .  'X-Mailer: PHP/' . phpversion();//Origonal messagemail($to, $subject, $message, $headers);//Return Message$reply = "Hello $name,Thankyou for your email, we will get back to you as soon as possible.Your Message was as follows:$message";mail($email, $replysubject, $reply, $replyHeaders);?>

I finally had time to try this on the server I use. The code I've put above worked for me in the exact way you seem to be looking for.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...