Authenticate Email Address in Contact Form

|

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

Twitter Updates

Subscribe

Enter your Email


Preview | Powered by FeedBlitz

Archives

Powered by Movable Type 4.21-en

Random Pix



Toni in the kitchen, July 07

Toni in the kitchen, July 07

Random Quote

Maya Angelou

In April, Maya Angelou was interviewed by Oprah on her 70+ birthday.

View the video clip of Oprah Winfrey's interview.

Oprah asked her what she thought of growing older.

And, there on television, she said it was "exciting." Regarding body changes, she said there were many, occurring every day...like her breasts.They seem to be in a race to see which will reach her waist first.

The audience laughed so hard they cried. She is such a simple and honest woman, with so much wisdom in her words!

Maya Angelou said this:

"I've learned that no matter what happens, or how bad it seems today, life does go on, and it will be better tomorrow."

"I've learned that you can tell a lot about a person by the way he/she handles these three things: a rainy day, lost luggage, and tangled Christmas tree lights."

"I've learned that regardless of your relationship with your parents, you'll miss them when they're gone from your life."

"I've learned that "making a living" is not the same thing as "making a life."

"I've learned that life sometimes gives you a second chance." I've learned that you shouldn't go through life with a catcher's mitt on both hands; you need to be able to throw some things back."

"I've learned that whenever I decide something with an open heart, I usually make the right decision."

"I've learned that even when I have pains, I don't have to be one."

"I've learned that every day you should reach out and touch someone. People love a warm hug, or just a friendly pat on the back."

"I've learned that I still have a lot to learn."

"I've learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel."

Recent Comments