Jump to content
Larry Ullman's Book Forums

How Carefully Do I Need To Filter Form Data Being Sent To An Email Address?


Recommended Posts

I have a form whose data is sent to an email address via the PHP mail() function. Obviously, when data is going into a database, the data needs to be carefully filtered using regexes, mysqli_real_escape_string, etc., but for data being sent to an email address, none of that seems essential.

 

If anything, a decent spam filter that stops bots seems sufficient. And to that end, does anyone have any good advice on how to handle potential bots, etc.?

 

Anyway, my main question is this: To what level should I be filtering form data being sent to an email address?

 

Thank you.

Link to comment
Share on other sites

Can't you just put a regular expression in a variable and check each input for that?

 


$naughty = '/Content-Type:|Bcc:|Cc:/i';
//when checking user input
if (preg_match($naughty, $user_input)){
error['input_name'] = 'Naughty...';
} else {
$input = true;
}

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...