Java and .NET components, FTP, TELNET, SMTP, POP3, IMAP, HTTP, SSH
Home Search Knowledge Base Support

Live Help

Click here for access to live technical support.

Java and .NET Help

iPod shuffle offer

For a limited time get a free iPod shuffle with qualifying purchase.

Click for details.


News

Secure FTP Factory for .NET released
Feb. 10, 2005

Secure FTP Factory 4.0 released
Dec. 20, 2004

Email Factory for .NET released
Nov. 1, 2004

SSH Factory released
Sep. 03, 2004

WebGalileo Faces released
Jun. 14, 2004


Tutorials

Retrieving email using C#
Oct. 29, 2004

SSH using Java
Feb. 26, 2004

Telnet using C#
Feb. 19, 2004

Scripting Telnet Sessions using Java
Oct. 23, 2003

Retrieving email from POP3 server using Java
Sep. 29, 2003

Secure FTP using Java
Sep. 15, 2003

... and more


Feedback

Request a feature or component

Request a Java or .NET component


 

Parsing Bounced E-Mails

By: Rick Stevens
March 1st 2005

Audience: Advanced

Many companies now provide some type of subscription-based, or opt-in notification service to their customers in order to keep their customers informed of new releases, special offers, etc. To do so, you might compose an email notice, extract the e-mail addresses from your database, then send the email notices to all the subscribers. Only to discover that some of your subscribers did not receive your notice. How do you find out which ones bounced? -- Do you manually check each bounced email against the subscriber database?

In this article, we'll discuss a simple means to parse a bounced email using the Email Factory for .NET component. Although this article references an example SMTP server, you can use the same principles when creating your own project.

You can download a free evaluation version of Email Factory for .NET. You can also download all the code you'll need for this article -– it will make things easier as we progress through the steps.

You should have the appropriate login credentials for your mail server in order to download emails.

What is a bounced Email?

In its simplest form, a bounced email is an email message that is returned because it could not be delivered. There are many reasons that an email message might be returned. A few reasons are, a wrong email address, a DNS resolution failure, a spam filter, a denied relay, or the recipient's email box is full. The reasons are commonly classified as either a "hard bounce" or a "soft bounce." A hard bounce is due to a permanent reason, such as a non-existent address. A soft bounce is due to a temporary reason, such as a full mailbox.

When an SMTP server is not able to deliver an email, for whatever reason, it does not care about the contents of the message when determining where to send the error notification. Most often it simply creates a failure notice and sends it back to the address specified in the From header. This is the basis of our example for this article.

In this example, we send a simple email to a recipient to inform them of a product upgrade. Our original example email message (including headers) is as follows.

Received: from user ([255.255.255.255])
	by dns.dnsserver.com (8.12.6/8.12.6) with SMTP id j22LE1AIBBA063
	for ; Wed, 2 Mar 2005 14:14:01 -0700 (MST)
	(envelope-from username@domainname.com)
From: "UserName" 
To: 
Subject: Product Update
Date: Wed, 2 Mar 2005 14:22:16 -0700
Message-ID: 
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409

We've updated our product!

Sincerely,
New Product Company

Our example SMTP server uses the From address value when determining where to send the error notification. The following is an example message body of the failure notice.

The original message was received at Wed, 2 Mar 2005 14:14:01 -0700 (MST)
from [255.255.255.255]

   ----- The following addresses had permanent fatal errors -----
<username@domainname.com>
    (reason: 550 Host unknown)

   ----- Transcript of session follows -----
550 5.1.2 ... Host unknown (Name server: domainname.com: host not found)

Our example SMTP server included certain headers in the failure notice. A Content-Type of multipart/report is sometimes used for administrative notices. See RFC1892 for more information. This provides another option to determine the cause of a bounced email. You could test the report-type attribute for the appropriate value. In this case, it indicates the delivery status.

Return-Path: 
Received: from localhost (localhost)
	by dns.dnsserver.com (8.12.6/8.12.6) id j22LE1AIBBA063;
	Wed, 2 Mar 2005 14:14:01 -0700 (MST)
	(envelope-from MAILER-DAEMON)
Date: Wed, 2 Mar 2005 14:14:01 -0700 (MST)
From: Mail Delivery Subsystem 
Message-Id: <200503022114.j22LE1AIBBA063@dns.dnsserver.com>
To: 
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
	boundary="j22LE1AIBBA063.1109798041/dns.dnsserver.com"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
X-UIDL: T!3_!%/h!!1l("!,X="!

Often times an attachment is included with the failure notice. The attachment may contain additional header information, such as Final-Recipient, Action, and Diagnostic-Code. Our example SMTP server provided the following attachment named ATT200503.DAT.

Reporting-MTA: dns; dns.dnsserver.com
Received-From-MTA: DNS; [255.255.255.255]
Arrival-Date: Wed, 2 Mar 2005 14:14:01 -0700 (MST)

Final-Recipient: RFC822; username@domainname.com
Action: failed
Status: 5.1.2
Remote-MTA: DNS; dnsserver.com
Diagnostic-Code: SMTP; 550 Host unknown
Last-Attempt-Date: Wed, 2 Mar 2005 14:14:01 -0700 (MST)

Based on the previous Content-Type attribute we know that this message is about the delivery status. The headers in this attachment provide the details. The Diagnostic-code indicates that the host could not be determined for the email address specified in the Final-Recipient header, therefore, the Action failed.

Page 1  Page 2  Page 3