Top10WebHosting

Open NavigationOpen Search
Everything related to web hosting.
  • Learning center
    • Move host guide
    • Compare Shared Hosting & VPS
    • SEO related
  • Hosting by features
    • Top web hosting
    • cPanel web hosting
    • PayPal web hostings
    • PHP Web Hosting
    • VPS Web Hosting
  • Coupons
    • Bluehost coupon 2017
  • Hosts overview
    • GreenGeeks Review
    • JustHost Overview.
    • Bluehost Overview
    • IXWebhosting Overview
    • Hostmonster Overview
    • Hostgator Overview.
    • SiteGround Overview
  • About
    • Contact Us
    • Disclosure
You are here: Home / email / PHP Smtp email checking.

PHP Smtp email checking.

April 24, 2012 by Wyng

While you can check syntax of an email address (valid format) but can’t validate the existence of an email address without checking with the email domain name.

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.

Example usage

// include SMTP Email Validation Class
require_once('smtp_validateEmail.class.php');

// the email to validate
$email = '[email protected]';
// an optional sender
$sender = '[email protected]';
// instantiate the class
$SMTP_Validator = new SMTP_validateEmail();
// turn on debugging if you want to view the SMTP transaction
$SMTP_Validator->debug = true;
// do the validation
$results = $SMTP_Validator->validate(array($email), $sender);
// view results
echo $email.' is '.($results[$email] ? 'valid' : 'invalid')."n";

// send email? 
if ($results[$email]) {
  //mail($email, 'Confirm Email', 'Please reply to this email to confirm', 'From:'.$sender."rn"); // send email
} else {
  echo 'The email addresses you entered is not valid';
}

Reference : http://code.google.com/p/php-smtp-email-validation/

Filed Under: email, php, tutorial

Back to top ▴

List of Most popular hosting plan


Our list of top web hosting plan with discounted entry price, good features with excellent support.

Hosts using the Most user friendly control panel


cPanel control panel has the most user friendly interface to control the Linux enviroment.

Hosts accepting PayPal


Stay safe, use Paypal to hide your credit cards from hosts.

Follow us on Social media

About Top10WebHosting.com

I manage & consult web developments for companies. And I have chance to use different web hosts by different client.

I am here to share some good & highlights of different hosts by features & rating.

Search this website

Copyright © Top10WebHosting.com 2002-2018. All Rights Reserved.