.NET Framework Developer Center > .NET Development Forums > .NET Framework Networking and Communication > [system.net.mail.smtpclient]: Does anyone know of a *real* way to validate a successful email send?
Ask a questionAsk a question
 

Answer[system.net.mail.smtpclient]: Does anyone know of a *real* way to validate a successful email send?

  • Wednesday, March 22, 2006 10:23 PMsbrickey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I've looked in the intellisense, online .Net docs, and on here...
    long story short i can send email but want to read the status code of those emails... preferably the SMTP status code.

    so far the only close solution to verifying a successful send is using the mailmsg.deliverynotificationoptions.. but that's hardly a solution... that is based on a return email for delivery notification...

    for catching errors it's easy enough... just try/catch it and grab the status code there... but i'm looking for something on the success/delay (delays can still be successful) status code as well.

    I'm looking for a status code (250 OK, 500 ERR, etc), not some return email - a *real* way.

    any help would be appreciated,
    -Scott

Answers

  • Thursday, March 23, 2006 12:46 AMDurgaprasad GortiModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    SMTP is store and forward. Means that that if the smtp server accepts there is no guarantee that it gets really delivered. So your way of finding out what happened is not quite accurate.

All Replies

  • Wednesday, March 22, 2006 10:39 PMDurgaprasad GortiModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What is the real scenario?
    You can count that the mail delivery is successful if the
    send is successful. The Class is supposed to abstact out all the
    details of the SMTP protocol so we don't expose the underlying status codes. In short it is successful if the send does not thrown an exception?
  • Wednesday, March 22, 2006 10:51 PMsbrickey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    i'm storing records for historical logs... I'd *ideally* like some sort of return-success struct containing status code and timestamp (since it may or may not be sync/async)... who knows if the SMTP server's queue is busy or not?... who knows if a delayed send goes through or not (ok so in this case it'd need some identifier and some way to later connect and query on the ID for status, but anyway). the point is to have accurate logs, not "logs that assume 500 if it's blank here" (ok so that's a little derogatory, to which i am sorry, but the point remains).

    any ideas?

    Thanks for your time,
    -Scott

  • Thursday, March 23, 2006 12:46 AMDurgaprasad GortiModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    SMTP is store and forward. Means that that if the smtp server accepts there is no guarantee that it gets really delivered. So your way of finding out what happened is not quite accurate.
  • Thursday, April 06, 2006 11:53 AMjohnalexander Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    What about using the logging?

    http://www.systemnetmail.com/faq/4.10.aspx

    Would this suffice?

    If not, you could use an SMTP server that you have admin rights to, and use the message tracking abilities on that server to validate the success/failure.  You could even parse through log files programatically to validate each message went through.  Seems like a lot of work, though.  SMTP is pretty darn reliable.  I don't know your business driver -- if you must have guaranteed delivery for legal reasons, or whatever -- but I think for most folks, SMTP is reliable enough.

     

  • Thursday, November 09, 2006 6:01 AMRizwanrs Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Assuming appropriate & unique 'subject' content of a mail, so when a mail is undelivered, then we get a return mail prefixed to 'subject' of a mail with "Undeliverable". Could be possible to relate the mail with status as failure.

    But how to continuously poll the mail server just for failure return mails? Performance as well as development wise how this approach would be?

    If anybody has this solution, then sample code would be of great help.

    Thanks & Regards

    Rizwan

     

  • Wednesday, April 22, 2009 6:41 AMParul Chaturvedi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Is there a way to know whether the recipient email address is invalid using System.Net.Mail or System.Web.Mail?
    We would want to track the emails that have bounced back without actually looking at the bounce back emails sent to the sender.

    If anyone can provide any suggestions i would be vey grateful.

    Thanks,
    Parul
  • Thursday, August 06, 2009 4:02 PMswpatech Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What about the ENVID parameter of the SMTP MAIL command. Is there any way to use that with this client?
  • Friday, November 06, 2009 3:45 PMEfran Cobisi [cobisi.com] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    What about validating the e-mail address/mailbox before sending the e-mail?

    In my company we use EmailVerify.NET (http://www.emailverify.net), a Microsoft .NET component which supports e-mail syntax checking, domain MX test and mailbox validation too.
    E-mail validation up to the mailbox level is easy as writing the following code block:

    var verifier = new EmailVerifier();
    var result = verifier.Verify("me@example.com", VerificationLevel.Mailbox);
    
    if (result.IsSuccess)
    {
       // Go on, send the message
    }
    

    Additional code samples can be found here.
    From their home page:

    EmailVerify.NET is a powerful .NET component which verifies email addresses using various techniques, including:
    • Syntax verification, according to RFC 2821 and RFC 2822
    • MX record lookup
    • Disposable email address (DEA) validation
    • SMTP availability check
    • Mailbox existence check, with greylisting support
    • Catch-all test

    It is completely written in managed code (C#) and is compliant with the Common Language Specification (CLS), so it can be used with any other .NET language, including VB.NET, C++/CLI, J#, IronPython, IronRuby and F#.

    The price for this component is very small (less than 50 bucks) and their support is one of the greatest I've ever found for a small software company like they are.
    Hope this helps.