faithless1
asked on
Email Regex
Hi,
I have a file with email addresses. I'm looking for a script to ensure that all of the email follow a proper regex. Please provide command usage details as well.
Thank you.
I have a file with email addresses. I'm looking for a script to ensure that all of the email follow a proper regex. Please provide command usage details as well.
Thank you.
Hi, it's not good etiquette to post the same issue multiple times on EE, as multiple experts can end up resolving the same issue - it's also a breach of EE rules. Can you please delete the most recent question you posted before anyone adds a comment, otherwise EE staff/volunteers will need to spend time cleaning it up.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks to sammySeltzer for the link - it links to the Google project which has more up-to-date code, which is the EmailAddressValidator.php file I have provided. Definitely split some points with him if you use my code!
ASKER
None of the codes are working...
$ sh EmailAddressValidator.php email_addresses.txt
tried php Email.... email_addresses.txt as well
: No such filelidator.php: 1: cannot open ?php
: not foundsValidator.php: 2:
: not foundsValidator.php: 3: /*
: not foundsValidator.php: 4:
EmailAddressValidator.php: 5: EmailAddressValidator: not found
: not foundsValidator.php: 6: http://code.google.com/p/php-email-address-validation/
: not foundsValidator.php: 7:
EmailAddressValidator.php: 8: Released: not found
: not foundsValidator.php: 9: http://www.opensource.org/licenses/bsd-license.php
: not foundsValidator.php: 10:
EmailAddressValidator.php: 11: Sample: not found
: not foundsValidator.php: 12: ----------------
EmailAddressValidator.php: 13: =: not found
: not foundsValidator.php: 13:
EmailAddressValidator.php: 14: Syntax error: "(" unexpected (expecting ")
validate-email-file.php (491 bytes) (File Type Details)
this returns all emails as invalid.
The other questions were deleted.
$ sh EmailAddressValidator.php email_addresses.txt
tried php Email.... email_addresses.txt as well
: No such filelidator.php: 1: cannot open ?php
: not foundsValidator.php: 2:
: not foundsValidator.php: 3: /*
: not foundsValidator.php: 4:
EmailAddressValidator.php:
: not foundsValidator.php: 6: http://code.google.com/p/php-email-address-validation/
: not foundsValidator.php: 7:
EmailAddressValidator.php:
: not foundsValidator.php: 9: http://www.opensource.org/licenses/bsd-license.php
: not foundsValidator.php: 10:
EmailAddressValidator.php:
: not foundsValidator.php: 12: ----------------
EmailAddressValidator.php:
: not foundsValidator.php: 13:
EmailAddressValidator.php:
validate-email-file.php (491 bytes) (File Type Details)
this returns all emails as invalid.
The other questions were deleted.
ASKER
How do I run this script on the command line?
http://php-email-address-validation.googlecode.com/svn/trunk/EmailAddressValidator.php
I have it saved as EmailAddressValidator.php and the emails are saved in emails.txt
I run:
php EmailAddressValidator.php emails.txt and nothing is being returned.
Thanks
http://php-email-address-validation.googlecode.com/svn/trunk/EmailAddressValidator.php
I have it saved as EmailAddressValidator.php and the emails are saved in emails.txt
I run:
php EmailAddressValidator.php emails.txt and nothing is being returned.
Thanks
Sorry -
1. save both php files to the same directory
2. go into that directory
3. put a copy of the email address file in there too
4. rename your email address file to "email_addresses.txt"
5. run this from the command line:
php validate-email-file.php
1. save both php files to the same directory
2. go into that directory
3. put a copy of the email address file in there too
4. rename your email address file to "email_addresses.txt"
5. run this from the command line:
php validate-email-file.php
Note that I've assumed your email address file contains one email address per line. If that's not the case, let me know the format and the code will need to be updated.
ASKER
Hi,
I already did that but all emails are returned as NOT valid
is NOT valid.5asdf@mail.com
is NOT valid.adsf@loomyow.com
is NOT valid.asdf@gmail.com
is NOT valid.baddsaf@gmail.com
is NOT valid.bsdfs@yahoo.fr
I already did that but all emails are returned as NOT valid
is NOT valid.5asdf@mail.com
is NOT valid.adsf@loomyow.com
is NOT valid.asdf@gmail.com
is NOT valid.baddsaf@gmail.com
is NOT valid.bsdfs@yahoo.fr
ASKER
In terms of the file, yes i have emails in a single row.
As it currently stands, the script only outputs invalid emails - all the ones you provided above start with a . character, which makes them invalid I believe. Do you want valid email addresses listed too?
Hmm actually, I might be wrong about that - valid email addresses should be listed too. Here's the output I got from my own example email_addresses.txt file:
<pre>Email address asdfjlkaj.asdf@foo.com is valid.
Email address blah2345@example.com is valid.
Email address nobody@example.com is valid.
Email address 234857%$^&@example.com is valid.
Email address .invalid@example.com is NOT valid.
</pre>
<pre>Email address asdfjlkaj.asdf@foo.com is valid.
Email address blah2345@example.com is valid.
Email address nobody@example.com is valid.
Email address 234857%$^&@example.com is valid.
Email address .invalid@example.com is NOT valid.
</pre>
To clarify, valid email addresses should be output, but email addresses starting with . are not valid.
ASKER
Same problems, The first example was output from unix here's output from a file I'm outputting info to
Email address jklikkk@yahoo.com
is NOT valid.
Email address jklikkk@yahoo.com
is NOT valid.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ran it with 3 lines
aaa@gmail.com
bbb@gmail.com
ccc@gmail.com
Still errors
aaa@gmail.com
bbb@gmail.com
ccc@gmail.com
Still errors
ASKER
can you reupload latest scripts?
ASKER
<pre>Email address aaa@gmail.com
is NOT valid.
Email address zzzz@gmail.com
is NOT valid.
Email address whois@gmail.com
is NOT valid.
</pre>
is NOT valid.
Email address zzzz@gmail.com
is NOT valid.
Email address whois@gmail.com
is NOT valid.
</pre>
ASKER
Thank you! Hope this one work better then the rest
http://www.addedbytes.com/code/email-address-validation/