Email Code
  Home arrow Email Code arrow Checking if Email address is deliverab...
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
EMAIL CODE

Checking if Email address is deliverable
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2002-06-17

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    SMPT protocol check of email address at preferred MX host or host.

    This returns nothing if email is valid, or a nice descriptive error message. It will split out the domain, lookup the preferred mailhost, connect to it an try to deliver at the given address. If no MX record is found it will try to deliver directly at the SMTP port. Since most mailservers say that the given address has valid syntax the only more waterproof check would be to send mail and wait for a reply.



    This is the fullest implementation

    By : datasmid

    <?php

    function checkemail($email){
    list($mailbox,$domain) = split('@',$email,2);
    $state = 'domain';

    // find preferred mailserver
    if(getmxrr($domain,$mailhosts,$pref)){
    asort($pref);
    foreach($pref as $preferred){
    $mailserver = $mailhosts[key($pref)];
    break;
    }
    $state = "trying mailserver $mailserver";
    $state = mailconnect($mailserver,$email);
    }else{
    // no mail exchange found try as host
    $state = "No MX, trying $domain";
    $state = mailconnect($domain,$email);
    }
    return $state;
    }

    function mailconnect($mailserver,$email){
    $myhostname = $SERVER_NAME;
    $connection = fsockopen($mailserver, 25);
    if($connection){
    $state = "connected to $mailserver";
    // Nothing to do with greeting
    //$smtpgreeting = fread($connection, 512);

    //if($smtpgreeting){
    fputs($connection, "HELO $myhostname\r\n");
    $hello = fgets($connection, 512);
    if($hello){
    $state = "chatting to $mailserver: $hello";
    fputs($connection, "MAIL FROM: <webserver@$myhostname>\r\n");
    $youok = fgets($connection, 512);
    if($youok){
    $state = "chatting to $mailserver: $youok";
    fputs($connection, "RCPT TO: <$newaddress>\r\n");
    $recepient = fgets($connection, 512);
    $state = "chatting to $mailserver: $recepient";
    if(ereg('250',$recepient)){
    fputs($connection, "QUIT\r\n");
    $deliverable = true;
    $state = false;
    }elseif(ereg('220',$recepient)){
    fputs($connection, "QUIT\r\n");
    $deliverable = true;
    $state = false;
    }else{
    $deliverable = false;
    $state = "RCPT? $recepient $newaddress";
    }
    }
    }else{
    $state = "$mailserver not accepting mail now, please try again.";
    }
    //}else{
    //$state = 'mailserver not greeting me';
    //break;
    //}
    }else{
    $state = "$mailserver not listening";
    }
    return $state;
    }
    ?>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Email Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    IBM DB2 Deep Compression ROI Tool

    The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times.
    FREE! Go There Now!


    NEW! Build Web services with transport-level security using Rational Application Developer V7, Part 1: Build Web services and Web services clients

    Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services.
    FREE! Go There Now!


    NEW! Did you say mainframe? e-kit

    Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise.
    FREE! Go There Now!


    NEW! Discovering the value of WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!


    NEW! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points.
    FREE! Go There Now!


    NEW! Project and Portfolio Management Executive Resource Kit

    Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle.
    FREE! Go There Now!


    NEW! Rational Modeling Extension for Microsoft.Net

    Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms.
    FREE! Go There Now!


    NEW! Rational Talks to You: Grady Booch on Architecture

    Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered!
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Process

    Visit IBM developerWorks to try the IBM SOA Sandbox for process. The SOA Sandbox for process focuses on providing a trial environment with the necessary tooling and components required to gain a better understanding of business processes and how to best improve existing business processes to derive value quickly.
    FREE! Go There Now!


    Refresh! IBM Rational Systems Development Solution eKit

    With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    EMAIL CODE ARTICLES

    - Basic Ajax contact form
    - Random validation image
    - tinySendMail
    - SaferMail 0.7
    - Smtp Auth Email Script
    - Search Mime Email Structure
    - PHP Text / HTML Email with Attachments 2.1
    - Simple way to send mail wih one attached Doc...
    - Generic POP3 Class
    - PHP Text / HTML Email with Unlimited Attachm...
    - Another SendMail
    - email with attachment
    - Get Email Addresses from Strings
    - EmailCode
    - Email Validation - Gone Wild





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek