+ Reply to Thread
Results 1 to 2 of 2

Thread: Check if mail format is valid

  1. #1
    mike
    Guest

    Check if mail format is valid

    How may i check if the mail format is valid ?
    Last edited by mike; 11-12-2012 at 03:52 AM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    13
    Here is a quick method to check if the mail format is on correct way.
    Code:
    sub ValidEmail
    {
       return 0 if $_[0] =~ /(?:[\.\-\_]{2,})|(?:@[\.\-\_])|(?:[\.\-\_]@)|(?:\A\.)/;
       return 1 if $_[0] =~ /^[\w\.\-\_]+\@\[?[\w\.\-\_]+\.(?:[\w\.\-\_]{2,}|[0-9])\]?$/;
       return 0;
    }
    if(ValidEmail('name@example.com') { print "OK" }
    else { print "Ouch!"; }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts