https://github.com/rgl/mailbouncedetector
Detects whether a MailKit email Message is a bounce message
https://github.com/rgl/mailbouncedetector
bounce bounce-messages mail mime
Last synced: about 2 months ago
JSON representation
Detects whether a MailKit email Message is a bounce message
- Host: GitHub
- URL: https://github.com/rgl/mailbouncedetector
- Owner: rgl
- License: mit
- Created: 2015-09-29T12:47:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-29T08:59:08.000Z (4 months ago)
- Last Synced: 2025-04-11T16:17:54.918Z (about 2 months ago)
- Topics: bounce, bounce-messages, mail, mime
- Language: C#
- Size: 51.8 KB
- Stars: 28
- Watchers: 3
- Forks: 12
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MailBounceDetector
[](https://github.com/rgl/MailBounceDetector/actions/workflows/build.yml)
this library detects whether a message is a [bounce message](https://en.wikipedia.org/wiki/Bounce_message).
this detects [standard](#standard-bounce-messages) and [qmail](#qmail-bounce-messages) bounce messages.
see the [unit tests](MailBounceDetector.Tests/BounceDetectorTests.cs) for an example on how that information is exposed by the library.
## Standard bounce messages
a bounce message is one that has (or is) a `multipart/report; report-type=delivery-status` MIME part. its comprised of two or three sub-parts:
1. the human readable description of the bounce. normally this is a `text/plain` or `text/html` part.
2. the machine readable description of the bounce. this is a `message/delivery-status` part.
3. the original message that bounced. this part is optional, and might not have the complete message. its useful to known some of the original message headers such as the `Message-Id`. this is normally a `message/rfc822` part.the most important part is the `message/delivery-status` part; it looks something like:
```plain
Content-Type: message/delivery-statusReporting-MTA: dns; PTPEDGE02.test.local
Final-recipient: RFC822;
[email protected]
Action: failed
Status: 5.1.1
Remote-MTA: dns; mx.google.com
X-Supplementary-Info:
```### Standard bounce messages references
* [RFC6522 about the `multipart/report` part: The Multipart/Report Media Type for the Reporting of Mail System Administrative Messages](https://tools.ietf.org/html/rfc6522)
* [RFC3464 about the `message/delivery-status` part: An Extensible Message Format for Delivery Status Notifications](https://tools.ietf.org/html/rfc3464)
* [RFC3463 about the `message/delivery-status` part status codes: Enhanced Mail System Status Codes](https://tools.ietf.org/html/rfc3463)## qmail bounce messages
a bounce message is one that is a `text/plain` (which can also be inside a `multipart/alternative`) MIME part, e.g.:
```plain
Date: 17 Mar 1996 03:54:40 -0000
From: [email protected]
To: [email protected]
Subject: failure noticeHi. This is the qmail-send program at silverton.berkeley.edu.
I'm afraid I wasn't able to deliver your message to the
following addresses. This is a permanent error; I've given up.
Sorry it didn't work out.:
Sorry, I couldn't find any host by that name.--- Below this line is a copy of the message.
Return-Path:
Received: (qmail 317 invoked by uid 7); 17 Mar 1996 03:54:38 -0000
Date: 17 Mar 1996 03:54:38 -0000
Message-ID: <[email protected]>
From: [email protected] (D. J. Bernstein)
To: [email protected]
Subject: are you there?Just checking.
```### qmail bounce messages references
* [The qmail-send Bounce Message Format (QSBMF)](http://cr.yp.to/proto/qsbmf.txt)