Forum Moderators: coopster

Message Too Old, No Replies

emailing form contents

         

surrealillusions

9:35 pm on Feb 6, 2008 (gmt 0)

10+ Year Member



Hi, i've read through the php tutorial/library topic about submitting email forms..however, this bit confuses me -

we put the email address entered from the form into the $to variable
$to = $_POST['email'];

we then create a subject
$subject = "Order from www.example.com";

then we build our headers
$headers .= "From: MySite Orders <orders@example.com>\r\n";
$headers .= "Cc: orders@example.com\r\n";
$headers .= "Return-Path: orders@example.com\r\n";
$headers .= "Reply-To: orders@example.com\r\n";

now these are stripped headers from what I use and I put \r\n but I normally only use \n, again depends on too many things to squabble about. You may have problems getting the Return-Path to show properly but that could be a configuration thing as well. there are just too many things that effect email to explain them all.

The $to = $_POST['email'] - surely your emailing it to the person that enters their email into the form..thats what it looks like to me, and its from your email. Surely they should be the other way round?
$to = you@youremail.com
and
$headers .="From: $_POST['email']"

?

:)

PHP_Chimp

1:07 pm on Feb 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



now these are stripped headers from what I use and I put \r\n but I normally only use \n, again depends on too many things to squabble about

Humm, not really. It depends on if the mail transfer agent is doing its job properly. From the manual -

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n).
Some content removed to save space
Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.

However as jatar_k (original poster) says this is a configuration issue, so there may well be nothing that you can do about it; but it is in the manual as this is obviously a common problem.

The $to = $_POST['email'] - surely your emailing it to the person that enters their email into the form..thats what it looks like to me, and its from your email. Surely they should be the other way round?
$to = you@youremail.com
and
$headers .="From: $_POST['email']"

From the original post -
$message = "Your order was successfully sent to www.example.com\n\n";
$message .= "First Name: " . $_POST['firstname'] . "\n";
$message .= "Last Name: " . $_POST['lastname'] . "\n";
$message .= "Email: " . $_POST['email'] . "\n";
$message .= "Product Requested: " . $_POST['product'] . "\n";
$message .= "Quantity: " . $_POST['qty'] . "\n\n";
$message .= "Thank you for using www.example.com\n\n";

So in this case you are emailing the person who placed the order a note to say that there order has been placed. So you want to send the email to the person, not to the company.
If you are sending a different message then you may well be sending the mail to the company, but in the example you are mailing a receipt to the customer.

A link to the original discussion we are talking about for the curious.
[webmasterworld.com...]

surrealillusions

5:19 pm on Feb 7, 2008 (gmt 0)

10+ Year Member



ah..gotcha now..

Is there an easy way to switch it around so it emails the company and not the user?

thanks

:)

PHP_Chimp

6:15 pm on Feb 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ye what you posted will email the company, not the customer.

I guess that most people will use the mail function for what you were getting at, and they will be emailing the company the results of an order.
The example was just looking at another use of the mail function, if there is some other method of notifying the company that it has a new order.

surrealillusions

6:50 pm on Feb 7, 2008 (gmt 0)

10+ Year Member



ok thanks..

i think i get it now..just need to work out whats going wrong with my form, as its not displaying correctly..but thats a whole different story..

:)