Validate Email, not syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hibba
Forum Commoner
Posts: 58
Joined: Fri Oct 29, 2004 11:37 pm

Validate Email, not syntax

Post by Hibba »

Alright, I need to check a list of emails to see if they are still valid. Is this possible? I have heard about MX records on a host, but it seems to just return True if the host is real. I want to check if 'user@host.com' is real or not.

Any suggestions?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

we've talked about this recently.. but here's a recap:
  • MX can work, but a lot of hosts are starting to deny lookups entirely, due to spammers.
  • sending an email is about the only semi-true way.. and even then, the server could have blackholing enabled. If you get a bounce, then you know it's an invalid, or disabled, or full email account.
Hibba
Forum Commoner
Posts: 58
Joined: Fri Oct 29, 2004 11:37 pm

Post by Hibba »

Bah, that's what I figured. Ok, so I have no problem sending an email, and then take the emails that I get back and update from there. SO new question:

What is a good way to collect all the bounced back email addresses (in some type of delimited format, array, etc.)?

Thanks.
Hibba
Forum Commoner
Posts: 58
Joined: Fri Oct 29, 2004 11:37 pm

Post by Hibba »

anybody got a suggestion for this?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You should be able to read the headers of the returning data as described in the RFC('s). Example;

Code: Select all

R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready
         S: HELO MIT-MC.ARPA
         R: 250 SU-SCORE.ARPA

         S: VRFY Crispin
         R: 250 Mark Crispin <Admin.MRC@SU-SCORE.ARPA>

         S: SEND FROM:<EAK@MIT-MC.ARPA>
         R: 250 OK

         S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
         R: 450 User not active now

         S: RSET
         R: 250 OK

         S: MAIL FROM:<EAK@MIT-MC.ARPA>
         R: 250 OK

         S: RCPT TO:<Admin.MRC@SU-SCORE.ARPA>
         R: 250 OK

         S: DATA
         R: 354 Start mail input; end with <CRLF>.<CRLF>
         S: Blah blah blah...
         S: ...etc. etc. etc.
         S: .
         R: 250 OK

         S: QUIT
         R: 221 SU-SCORE.ARPA Service closing transmission channel
The R: XXX gives you a status of the sendt action, so... By scanning the returned mails for the particular error codes, you should be able to find what you need.

Goodle for rfc mail errors or similiar for more info.

Edit: Note, that I'm not sure this is the way to do it. Havn't dealt with it myself, but it felt like an interesting idea.
Hibba
Forum Commoner
Posts: 58
Joined: Fri Oct 29, 2004 11:37 pm

Post by Hibba »

Sorry, but that info does not make any sense to me.
Post Reply