Forum Moderators: coopster

Message Too Old, No Replies

Form Mails being returned with Sender "nobody"

How to get rid of "nobody"

         

BeeDeeDubbleU

9:06 am on Nov 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am using the following common formmail script.

$fmt_Response=implode("", file("http://www.domain_name.co.uk/thank_you_page.htm"));
$fmt_Mail=implode("", file("thehttfilename.htt"));
while(list($Key, $Val)= each($HTTP_POST_VARS)) {
$fmt_Response=str_replace("{$key}", $Val, $fmt_Response);
$fmt_Mail=str_replace("{$Key}", $Val, $fmt_Mail);
}
mail($HTTP_POST_VARS["recipient"], $HTTP_POST_VARS["subject"], $fmt_Mail);
echo $fmt_Response;
?>

It works great but the mail arrives from the server with the "from" field set as "nobody". Can anyone tell me how to set this to something more meaningful? I don't need it to return the sender's email address. It would be fine if I could just set it to a constant, like from "Website Form Submission".

(Sorry if this is garbled but I don't do PHP).

bulkit

1:21 pm on Nov 24, 2005 (gmt 0)

10+ Year Member




<?
$sendEmail='youremail@youremail.com';
$additional_headers ="From: ".$sendEmail."" . "\r\n" . "Reply-To: ".$sendEmail."" . "\r\n";
$fmt_Response=implode("", file("http://www.domain_name.co.uk/thank_you_page.htm"));
$fmt_Mail=implode("", file("thehttfilename.htt"));
while(list($Key, $Val)= each($HTTP_POST_VARS)) {
$fmt_Response=str_replace("{$key}", $Val, $fmt_Response);
$fmt_Mail=str_replace("{$Key}", $Val, $fmt_Mail);
}
mail($HTTP_POST_VARS["recipient"], $HTTP_POST_VARS["subject"], $fmt_Maill,$additional_headers);
echo $fmt_Response;
?>

bulkit

1:22 pm on Nov 24, 2005 (gmt 0)

10+ Year Member



sorry typo.. the mail command should read


mail($HTTP_POST_VARS["recipient"], $HTTP_POST_VARS["subject"], $fmt_Mail,$additional_headers);

BeeDeeDubbleU

2:31 pm on Nov 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you for that. Does this return the senders email address?

jatar_k

5:41 pm on Nov 25, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you would need to put their email into $sendEmail for that snippet or replace $sendEmail with the actual variable it is storing their email address.

Another observation, you really don't want to be using the user submitted data right in the mail call, that snippet you originally have looks like an invitation for abuse.