Okay, gang, I've pulled out almost all my hair, so I need some help.
I have several sites with very normal looking contact us forms on them. Fill them out, and the content is mailed to the Web site owner using the mail() function. In recent months, however, these forms have been exploited. It is unclear if they are being used to send SPAM or if this only is the intent, but I occasionally will get three or four contact forms in a row that clearly are being hit by some script.
These emails came across with some fields blank. So I required all fields.
The emails had random characters typed in, so I required that the email address be authentic. The emails send a reply to the person completing the form. The reply comes from my address. However, now I'm getting the replies with my address in the TO address and the FROM address.
So, I started getting the IP Address of the sender, requiring it, and putting that at the bottom of the emails. I try it, and it works. When these SPAMMING scripts hit it, the email that comes to me has MY EMAIL ADDRESS where the IP address is supposed to be.
All of my headers end with \r\n. And yet I'm still getting these scripted replies. I changed the file names in case they were coded in some place, and I even took the contact us form off the menu, leaving it as a link inside one page. No luck. They're still coming.
My code that prepares and sends the mail is below. Anyone have any suggestions?
if (@$_POST['emailAddress']) {
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['emailAddress'])) {
$emailto2 = $_POST['emailAddress'];
$subject2 = "Thank you for contacting Us";
$headers="From: [my email address] \r\n";
$headers.="Return-Path: [my email address]" . "\r\n";
$message2 = "Blah blah blah blah ...
$_POST[ip]";
mail($emailto2, $subject2, $message2, $headers);
}
}