Forum Moderators: open
A robot is pointed at your script. There are a good number of ways to thwart these, the most important thing you can do is have your script log all raw input from forms and treat it like the poison it is.
The greatest danger here is if they are able to modify the headers via the input fields. That is, if I realize your subject or mail-from field goes directly into an email, and I can add a newline to that input field, I can do this:
$_POST['subject'] = 'Hi\nBCC:address1@example.com,address2@example.com....';
In reality a \n is not used, a hex or octal equivalent is sent to bypass normal filtering.
You get one email. Your account is used to send thousands via BCC and you never know it. Log your data to see what they are up to.
Form abuse thread [webmasterworld.com] (one of many.)
A captchka might help, but it's not permanent and can be beaten (I've seen it done on vBulletin.) Depends on how determined they are. Some of the advice from that thread along the same lines, and much more simple, generate a random question (What is five plus six?")
No matter what works, you always want to know what's being input. Logging is the easiest thing to do in *any* server side language. For PHP:
// Define your log somewhere, make sure it's writable:
$mail_log = '/full/path/to/log/off/domain/root/if/possible/mail-log.txt';
$max_log_size = 100000; // So it doesn't become a hog
$filemode = (filesize($mail_log) >= $max_log_size)?"w":"a";
$ip = getenv('REMOTE_ADDR');
$currDate=date("D, m-d-Y h:i:s A");
$input_content = "
============================================
DATE/TIME: $currDate IP: $ip
============================================
";
foreach ($_POST as $key => $value) {
$input_content .= $key . ": " . $value . "\n";
}
if (is_writable($mail_log)) {
if (!$file = fopen($mail_log,$filemode)) {
die("Cannot open $mail_log in $filemode mode");
}
if (fwrite($file, $input_content) === FALSE) {
die("Cannot write to $mail_log");
}
fclose($file);
}
else { die("Mail log is not writable"); }
die would actually be a reference to a templated output, and while going through the input, add a hook to check for spammy patterns - but this is how you start knowing the enemy.