I've spent the morning trying to find an email script that will check the validity of an email address. I'm still having problems with spammers using my contact form. Every day I'm getting loads of unwanted emails. The spammers are using email addresses that are not authentic, e.g. asdf@fdsa.net. Even the name of the sender is something like "asdf". There seems to be plenty of options for checking on the validity of an email address. It just checks that the syntax is correct, e.g. somebody @ somewhere.something. Authenticating the email address is a whole other ball game, and one not easily implemented.
I'm starting to think I may have to remove the contact form entirely. Leaving a comment is probably sufficient for site feedback, because I'm notified of all comments. However, I don't WANT to have to do this. Surely someone can come up with a script that actually authenticates a user's email address, and forwards the contents to you only if it is authentic. A message could say to the spammer: Sorry buddy, you entered a false email address. You have wasted your time and ours.
Okay, it's another couple of hours later and I've read lots of articles about authenticating an email address. I found a piece of code that actually does this, and have implemented it into the dodosmail.php script and it works. I'm cheering. Elise has an article on how to implement a contact form on your site using DodosMail. Download the script and follow the instructions.
Open dodosmail.php in a text editor and look for the following piece of code (It's at the end):
function check_email($email) {
if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {
return true;
}
return false;
}
Replace the text with this:
function check_email($email) {
// checks proper syntax
if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ){
list($username,$domain)=split('@',$email);
if(!getmxrr ($domain,$mxhosts)){
return false;
}
return true;
}
return false;
}
This piece of code will validate the proper format for an email address, and check whether the email domain is a real domain. I'm hopeful that this will solve the problem with spammers using my comment form. During the test, it worked beautifully, but once again, time will tell.

Leave a comment