Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Email Validation

by Anonymous Monk
on Nov 14, 2001 at 11:24 UTC ( #125298=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I recently developed a script for someone that I host on my server, they run a site which allows users to enter their email address to signup for a contest, At the moment I only have a very simple regex to validate the syntax of the email - this contest site gets about 1,000 signups a day, of which of the emails the server sends out, I'm getting about 50 bounce and just sit on the server waiting for a retry, mainly this appears to be due to users spelling their email address wrong..

Then I stumbled upon Email::Valid yesterday which appears to also do an mx check on a domain, my concern with so many emails to check that this will cause a very high load on the server..
Anyone have any opinions?

Replies are listed 'Best First'.
Re: Email Validation
by rob_au (Abbot) on Nov 14, 2001 at 11:48 UTC
    While it is unlikely that MX domain checks alone will cause high server load (depending on the network and DNS configuration), you can disable this functionality within Email::Valid by setting the parameter -mxcheck to 0 - This allows you to merely check the email as valid with regard to RFC822 specification or alike. eg.

    print (Email::Valid->address( -address => 'email@address.com', -mxcheck => 0 ) ? 'yes' : 'no');

    With regard to the number of email addresses getting bounced and ending up in retry or bad message queues, it may be worth either modifying your MTA configuration to minimise retries before delivery failure or rewriting the mail code to attempt SMTP delivery to the lowest preference mail exchanger directly and discarding the message if delivery is not achieved within a set number of attempts. You could also set up a mailbox directed to /dev/null for bounce messages.

    There is of course a balance which you will be able to find between server load elevated by Email::Valid MX domain lookups and repeated MTA delivery attempts. My guess is that the load increase attributable to MX domain lookups will be negligible.

    Good luck.

     

    Ooohhh, Rob no beer function well without!

Re: Email Validation
by McD (Chaplain) on Nov 14, 2001 at 17:15 UTC
    Email::Valid is probably your best bet - any of the less rigourous methods proposed are simply biding time until they fail to validate an otherwise perfectly functional address.

    Email addresses are suprisingly complicated beasties - Mastering Regular Expressions has a regex to match valid addresses which will curl your hair - you can find it here.

    But in any case, you need to deal with failure notices - any mail, even mail to valid addresses, can fail to deliver for a variety of reasons.

    Peace,
    -McD

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://125298]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2019-11-22 17:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (113 votes). Check out past polls.

    Notices?