SMTP is a core Internet protocol used to transfer e-mail messages between servers (first defined in RFC 821 in 1982). This contrasts with protocols such as POP3 and IMAP, which are used by messaging clients to retrieve e-mail. SMTP servers look at the destination address of a message and contact the target mail server directly. SMTP was designed to be a reliable message delivery system. Reliable in this case means that a message handled by SMTP is intended to get to its destination or generate an error message accordingly.
Email Syntax can check whether an email address has a valid format(by using regular expression), however, in order to check if the email address actually exists, you will have to query the email domain for the existence of the email address.
The PHP class encapsulates the SMTP transation between the remote domain, as well as the DNS lookup for the Mail Transfer Agent (MTA) responsible for that domain.
The class can take a number of email addresses, and return whether they are valid or not. It will group together emails with the same domain, and create a single SMTP connection to the MTA for those emails for efficiency.
This class is meant to be a secondary validation of an email address after the email syntax is validated. It can also provide intermediate email validation before sending a confirmation email to the email address, which does not provide user feedback if the email is invalid – and thus loss of users.
<br /> <?php</div><br /> // include SMTP Email Validation Class<br /> require_once('smtp_validateEmail.class.php');</p> <p>// the email to validate<br /> $email = $_POST['email'];<br /> // an optional sender<br /> $sender = $_POST['email'];<br /> // instantiate the class<br /> $SMTP_Validator = new SMTP_validateEmail();<br /> // turn on debugging if you want to view the SMTP transaction<br /> $SMTP_Validator->debug = true;<br /> // do the validation<br /> $results = $SMTP_Validator->validate(array($email), $sender);<br /> echo ($results[$email] ? 'valid' : 'invalid');</p> <p>?></p> <p>
Here is the link to download the above php class file: smtp_validateEmail.class