Validate emails with SMTP and PHP


/ Published in: PHP
Save to your folder(s)

This function validate a mail address in a smart way: if the address to validate has a correct syntax (checked with regular expression), it tries to connect to the mx server of the address. This means that the program have to use the smtp protocol to talk with each mx server registered in the dns for that domain address.
When a connection with an mx server is established, the program presents himself with the $probe_address (if no probe_address is specified it will use the SERVER_ADMIN setting of the php.ini file) and asks to send a mail message to the address to validate. If the server responds that the destination mailbox is ok, it stops and return ok value, else it gives you the bad answer of the mail server.

URL: http://www.barattalo.it/2009/12/27/validate-email-with-smtp/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.