Drop Shadow

Checking for spam

If you want to check your form submissions for likely webspam, use the “maybeSpam” method. For example:

IF ($message->maybeSpam()): echo "Not sending message: might be spam."; ELSE: $message->queue(); ENDIF;

If there’s only a specific bit of text that you want checked for spamminess, you can give that text to the method.

$comment = $_POST['comment']; IF ($message->maybeSpam($comment)): echo "Not sending message: might be spam."; ELSE: $message->queue(); ENDIF;

  • Any text with six or more URLs in it will be considered spammy.
  • Any text that contains a phpBB-style URL (“[URL=…]”) will be considered spammy.
  • If the client computer is in a list of spam sender IP addresses, the text will be considered spammy.

Note that you don’t have to not send the message when you discover that it’s spammy. You might just choose to send it to a smaller list of people. It’s possible (though unlikely) that spammy text isn’t really spam.

Remote Black List

If you want to include a remote black list in your spam check, use “fullSpamCheck” instead of “maybeSpam”. The fullSpamCheck does all of the maybeSpam checks, and then also does a check against a remote black list.

Note that if the remote black list’s server is down, your form submissions will be extremely slow.

Looking for spam text

If you want to reject messages based on whether they contain specific texts, you can use the contains method.

IF ($message->contains('make money now')): echo "Not sending message: money spam."; ELSE: $message->queue(); ENDIF;

You can also provide an array of text to look for:

$spamtexts = array( 'make money now', 'make money then', 'treasure in the middle east', ); $message->contains($spamtexts);

By default, contains will search the full message, but, like maybeSpam, you can also provide specific text to look in; send the “haystack” as the second parameter.