Page 1 of 1

"Reply-To:" not functioning

Posted: Thu Oct 05, 2006 8:39 pm
by Leao
Hi,

I've set-up an email form that sends variables to the attached PHP script. The message is sent OK. The only problem is the "Reply-To" feature. When I click Reply in my email account on receipt of a message sent via the form the address in the 'Reply' field of my email is X-Mailer: PHP/4.3.11@linhost199.prod.mesa1.secureserver.net rather than the email address contained in the $yourname variable.

Any ideas about what I'm doing wrong? I've tried swapping the order of the headers around a bit but it doesn't seem to solve the problem.

Many, many thanks,

leo

Code: Select all

<?

$to = 'myname@mydomain.org';

$subject = 'St. Patrick\'s message';

$body = "You have received a message via the St. Patrick's website. The details of the message are listed below...\n\nName: $yourname\nEmail: $youremail\nMessage: $yourmessage";

$body = wordwrap($body, 70);

$headers = "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: myname@mydomain.org\r\n"; 
$headers .= "Return-Path: myname@mydomain.org\r\n";
$headers .= "Reply-To: $youremail";
$headers .= 'X-Mailer: PHP/' . phpversion()."\r\n";

mail($to, $subject, $body, $headers, "-fmyname@mydomain.org");

?>

Posted: Thu Oct 05, 2006 9:18 pm
by volka
there's a \r\n after every header except Reply-To

Posted: Thu Oct 05, 2006 9:26 pm
by Leao
I modified it to add the \r\n (see below) but the same prob still persisted. Any other ideas?

Cheers

leo

Code: Select all

<?

$to = 'myname@mydomain.org';

$subject = 'St. Patrick\'s message';

$body = "You have received a message via the St. Patrick's website. The details of the message are listed below...\n\nName: $yourname\nEmail: $youremail\nMessage: $yourmessage";

$body = wordwrap($body, 70);

$headers = "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: myname@mydomain.org\r\n";
$headers .= "Return-Path: myname@mydomain.org\r\n";
$headers .= "Reply-To: $youremail\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion()."\r\n";

mail($to, $subject, $body, $headers, "-fmyname@mydomain.org");

?>

Posted: Fri Oct 06, 2006 2:13 am
by RobertGonzalez
Where are you setting the vars that are inside the body of the script? Have you echoed those out to make sure they contain data?

Posted: Fri Oct 06, 2006 7:49 am
by Leao
Everah wrote:Where are you setting the vars that are inside the body of the script? Have you echoed those out to make sure they contain data?
Hi,

I'm setting the variables in a form in a Flash .swf file. It works - when someone uses the form I receive an email with all the variables completed. The only problem is the 'Reply-To' element of the PHP script that doesn't seem to work. As I said, when I receive an email via the form and click Reply the Reply-To address is X-Mailer: PHP/4.3.11@linhost199.prod.mesa1.secureserver.net rather than the email address contained in the $yourname variable.

Posted: Fri Oct 06, 2006 7:52 am
by volka
Do not use mail() but echo $headers. Does it print the expected data?

Code: Select all

<?php
$to = 'myname@mydomain.org';

$subject = 'St. Patrick\'s message';

$body = "You have received a message via the St. Patrick's website. The details of the message are listed below...\n\nName: $yourname\nEmail: $youremail\nMessage: $yourmessage";

$body = wordwrap($body, 70);

$headers = "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: myname@mydomain.org\r\n";
$headers .= "Return-Path: myname@mydomain.org\r\n";
$headers .= "Reply-To: $youremail\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion()."\r\n";


echo '<pre>', htmlentities("mail($to, $subject, $body, $headers, \"-fmyname@mydomain.org\");"), "</pre>\n";
?>

Posted: Mon Oct 09, 2006 8:55 am
by Leao
I got it to work with the following script.

Cheers

Code: Select all

<?
$to = 'mail@mydomain.org';

$subject = 'St. Patrick\'s message';

$body = "You have received a message via the St. Patrick's website. The details of the message are listed below...\n\nName: $yourname\nEmail: $youremail\nMessage: $yourmessage";

$body = wordwrap($body, 70);

$headers = "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: mail@mydomain.org\r\n";
$headers .= "Return-Path:mail@mydomain.org\r\n";
$headers .= "Reply-To: $youremail\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion()."\r\n";

mail($to, $subject, $body, $headers, "-fmail@mydomain.org.org");
?>