ISP closes php form because of spam abuse

Hi experts, my ISP says that my simple php script that handles a simple contact form is abused by spammers. What may I do to redeem this?

The script recides in a separate file from the form:
<?
header("Location:../index.php");
if ($REQUEST_METHOD == "POST") {
 
 
$email = $HTTP_POST_VARS[email];
$mailto = "name@domain.com";
$mailsubj = "Response from $name";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "This is a message from $name:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

echo("Thanks.");

}  
?>

Thanks
LVL 2
Sparkle101Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard QuadlingSenior Software DeveloperCommented:
A quick lesson.

EVERYTHING THAT A USER SUPPLIES IS BAD.

Here end'th the lesson.

Personally, I would take a look at

http://www.tectite.com/formmailpage.php

and

http://phpfmg.sourceforge.net/home.php
0
waygoodCommented:
If I put a form on my website that posts to yours, your script will send out emails for me.
All I'd have to do is supply the 'email' variable and put extra header information in it too, like cc or bcc.

You should detect where your post is coming from and validate all entries, before sending anything out.

To ensure people use your form and not just submit from somewhere else, you could also set a session variable with a random value when creating the form, including it in a hidden value, and when its submitted match them up.

Although most of these can be faked, good validation should be enough to prevent spammers sending out emails via your site.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sparkle101Author Commented:
Yes, I found out this too. I finally ended up with this script that detects cc and bcc and other and sends an error:

<?php

$error = "";

// get all the email form data

$ems = "";

// stop email server hacks
$ems .= $name;
$ems .= $email;
$ems .= $message;


if ( stristr( $ems, "content-type" ) || stristr( $ems, "multipart/mixed" ) || stristr( $ems, "boundary" ) || stristr( $ems, "cc:" ) || stristr( $ems, "multi-part message in mime format" ) || stristr( $ems, 'to:' ) || eregi( "(%[a-f0-9])", $ems ) || stristr( $ems, "0x" ))
// the last two are in case they try using hex or other non standard characters
{
$error .= "<p>Behave!!</p>";
}

if ( $error )
{
echo $error;
}
else
{


@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes("Responce from my form");
$text = stripslashes($message);
mail('myname@somedomain.com',$subject,$text,"From: $name <$email>");
header("location:../thanks.php");
}
?>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.