wagga2650 Posted September 21, 2010 Share Posted September 21, 2010 Hi ll, I have a php mail script I wrote and it works quite well except one little part On my web page I have a form field called email and in my php script I want to use the data from that field to be place in the cc and reply-to field. The cc part works but not the reply-to. Can someone please take a look at my code and see where it is wrong if possible. Thanks in advance <? //change this to your email. $to = "myemail@mail.com"; $from = "Website Support"; $subject = "Website Support Enquiry"; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; /*options to send to cc+bcc+reply-to you can use either a hidden field in antenna and use the variable to suit eg $headers .= "Cc: $cc\r\n"; or you can use the fields in this manner eg $headers .= "Cc: youremail@domain.com\r\n"; */ $headers .= "Cc: $email\r\n"; //$headers .= "Bcc: youremail@domain.com\r\n"; $headers .= "Reply-To: $email"; //begin of HTML message $message = <<<EOF <table style='background-color: white; font-size:12px' cellpadding='3' cellspacing='3'> <tr> <td><b>Name</b></td> <td>$name</td> </tr> <tr> <td><b>Subject</b></td> <td>$subject <b>Email:</b> $email <b>Phone:</b> $phone </td> </tr> <tr> <td><b>Address</b></td> <td>$address</td> </tr> <tr> <td><b>Type</b></td> <td>$type</td> </tr> <tr> <td><b>Message</b></td> <td>$message</td> </tr> </table> EOF; //end of message // now lets send the email. // mail($to, $subject, $message, $headers); if ( mail($to,$subject,$message,$headers) ) { //header("Location: cart.htm"); echo "<br><br>Your mail has been sent"; } else { // header("Location: http://www.yourerrorpage.com"); echo "The email has failed! Please press the back button on your browser and try again"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/213995-setting-the-reply-to-in-my-mail-script/ Share on other sites More sharing options...
beta0x64 Posted September 22, 2010 Share Posted September 22, 2010 I have an idea of what might be causing this. We'll go in varying levels of severity/debugging. Try putting the reply-to immediately after the from. Make sure to \r\n it. If the new last header (Cc:) doesn't work, then you can assume that you need a final \r\n, which is normal in HTTP packets (I'm not sure about SMTP). From RFC2822 (http://www.faqs.org/rfcs/rfc2822.html), 3.6.2. Originator fields The originator fields of a message consist of the from field, the sender field (when applicable), and optionally the reply-to field. The from field consists of the field name "From" and a comma-separated list of one or more mailbox specifications. If the from field contains more than one mailbox specification in the mailbox-list, then the sender field, containing the field name "Sender" and a single mailbox specification, MUST appear in the message. In either case, an optional reply-to field MAY also be included, which contains the field name "Reply-To" and a comma-separated list of one or more addresses. from = "From:" mailbox-list CRLF sender = "Sender:" mailbox CRLF reply-to = "Reply-To:" address-list CRLF Quote Link to comment https://forums.phpfreaks.com/topic/213995-setting-the-reply-to-in-my-mail-script/#findComment-1114294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.