Giter VIP home page Giter VIP logo

mailbouncedetector's Introduction

MailBounceDetector

Build status

this library detects whether a message is a bounce message.

this detects standard and qmail bounce messages.

see the unit tests 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:

Content-Type: message/delivery-status

Reporting-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: <mx.google.com #5.1.1 smtp;550-5.1.1 The email account
    that you tried to reach does not exist.Please try 550-5.1.1 double-checking
the recipient's email address for typos or 550-5.1.1 unnecessary spaces.
    Learn more at 550 5.1.1  https://support.google.com/mail/answer/6596
    om11si19081667wic.29 - gsmtp>

Standard bounce messages references

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.:

Date: 17 Mar 1996 03:54:40 -0000
From: [email protected]
To: [email protected]
Subject: failure notice

Hi. 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.

<[email protected]>:
Sorry, I couldn't find any host by that name.

--- Below this line is a copy of the message.

Return-Path: <[email protected]>
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

mailbouncedetector's People

Contributors

rgl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mailbouncedetector's Issues

Issues with status 5.1.64 & 5.1.10

I have an issue with status codes 5.1.64 & 5.1.10, which seem to be Outlook.com / Exchange specific. I couldn't find them in the RFC. So, the question is, should (and could) they be added to the statusCodes? As example:

{ 110, "not found by SMTP address lookup" },
{ 764, "TenantAttribution; Relay Access Denied"}

Support net45 or net451 profiles on NuGet packages

Hi,

I was interested in using this package, but it's NuGet package only provides binaries for net452 profile. Would you be willing to provide nuget packages supporting net45 or net451 profiles?

Regards
Pablo

Bounce mail gets undedected

Maybe I am doing something wrong, but a clear bounce message is not recognized as such.
I am reading messages from a dedicated mailbox:
foreach (var uid in uids) {
var message = await inbox.GetMessageAsync (uid);
and than processing the message:
var result = BounceDetector.Detect(message);

This returns as not a bounce message for

Could not deliver message to the following recipient(s):

Failed Recipient: [email protected]
Reason: Remote host said: 550 5.1.1 The email account that you tried to reach does not exist. Please try
5.1.1 double-checking the recipient's email address for typos or
5.1.1 unnecessary spaces. Learn more at
5.1.1 https://support.google.com/mail/?p=SuchUser 4-v6si5409935edh.451 - gsmtp

Unable to cast object of type 'MimeKit.TextPart' to type 'MimeKit.MessagePart'

I have this
System.InvalidCastException: Unable to cast object of type 'MimeKit.TextPart' to type 'MimeKit.MessagePart'.
at MailBounceDetector.BounceDetectResult..ctor(MimeMessage message, MimeEntity deliveryNotification, MessageDeliveryStatus deliveryStatus, MimeEntity undeliveredMessagePart)
at MailBounceDetector.StandardBounceDetector.Detect(MimeMessage message)
at MailBounceDetector.BounceDetector.Detect(MimeMessage message)

New status codes mostly for Outlook.

private static readonly IDictionary<int, string> CombinedStatusCodes = new Dictionary<int, string>
    {
        { 00, "Not Applicable" },
        { 10, "Other address status" },
        { 11, "Bad destination mailbox address" },
        { 12, "Bad destination system address" },
        { 13, "Bad destination mailbox address syntax" },
        { 14, "Destination mailbox address ambiguous" },
        { 15, "Destination mailbox address valid" },
        { 16, "Mailbox has moved" },
        { 17, "Bad sender\'s mailbox address syntax" },
        { 18, "Bad sender\'s system address" },

        { 20, "Other or undefined mailbox status" },
        { 21, "Mailbox disabled, not accepting messages" },
        { 22, "Mailbox full" },
        { 23, "Message length exceeds administrative limit." },
        { 24, "Mailing list expansion problem" },

        { 30, "Other or undefined mail system status" },
        { 31, "Mail system full" },
        { 32, "System not accepting network messages" },
        { 33, "System not capable of selected features" },
        { 34, "Message too big for system" },

        { 40, "Other or undefined network or routing status" },
        { 41, "No answer from host" },
        { 42, "Bad connection" },
        { 43, "Routing server failure" },
        { 44, "Unable to route" },
        { 45, "Network congestion" },
        { 46, "Routing loop detected" },
        { 47, "Delivery time/message expired" },

        { 50, "Other or undefined protocol status" },
        { 51, "Invalid command" },
        { 52, "Syntax error" },
        { 53, "Too many recipients" },
        { 54, "Invalid command arguments" },
        { 55, "Wrong protocol version" },

        { 60, "Other or undefined media error" },
        { 61, "Media not supported" },
        { 62, "Conversion required and prohibited" },
        { 63, "Conversion required but not supported" },
        { 64, "Conversion with loss performed" },
        { 65, "Conversion failed" },

        { 70, "Other or undefined security status" },
        { 71, "Delivery not authorized, message refused" },
        { 72, "Mailing list expansion prohibited" },
        { 73, "Security conversion required but not possible" },
        { 74, "Security features not supported" },
        { 75, "Cryptographic failure" },
        { 76, "Cryptographic algorithm not supported" },
        { 77, "Message integrity failure" },
        { 110, "Not found by SMTP address lookup" },
        { 190, "Your message can't be sent because you've reached your daily limit for message recipients" },
        { 414, "Routing loop detected" },
        { 611, "Invalid characters" },
        { 712, "Sender was not authenticated by organization"},
        { 713, "Sender was not authenticated for public folder"},
        { 723, "The message was rejected because of Sender Policy Framework violation"},
        { 725, "Access denied, the sending IPv6 address [2a01:111:f200:2004::240] must have a reverse DNS record"},
        { 726, "Access denied, a message sent over IPv6 [2a01:111:f200:2004::240] must pass either SPF or DKIM validation, this message is not signed"},
        { 757, "Client was not authenticated to send anonymous mail during MAIL FROM"},
        { 764, "TenantAttribution; Relay Access Denied"},
        { 2121, "Recipient's per hour message receive limit from specific sender exceeded" },
        { 2122, "Recipient's per hour message receive limit exceeded" },
        { 3190, "Journaling on-premises messages to Microsoft 365 or Office 365 not supported when Journaling Archive is disabled" },
        { 4300, "Message expired" },
        { 4316, "Connection refused" },
        { 7124, "Sender not in allowed-senders list" },
        { 7133, "Sender not authenticated for group" },
        { 7134, "Sender was not authenticated for mailbox" },
        { 7135, "Sender was not authenticated for public folder"},
        { 7136, "Sender was not authenticated"},
        { 7321, "Starttls-not-supported: Destination mail server must support TLS to receive mail" },
        { 7322, "Certificate-expired: Destination mail server's certificate is expired" },
        { 7323, "Tlsa-invalid: The domain failed DANE validation" },
        { 7324, "Dnssec-invalid: Destination domain returned invalid DNSSEC records" },
        { 7325, "Certificate-host-mismatch: Remote certificate MUST have a common name or subject alternative name matching the hostname (DANE)" },
        { 7500, "Access denied, please try again later" },  // 4.7.500-699
        { 7501, "Access denied, spam abuse detected" },
        { 7502, "Access denied, banned sender" },
        { 7503, "Access denied, banned sender" },
        { 7504, "Recipient address rejected: Access denied" },
        { 7505, "Access denied, banned recipient" },
        { 7506, "Access Denied, Bad HELO" },
        { 7507, "Access denied, rejected by recipient" },
        { 7508, "Access denied, [$SenderIPAddress] has exceeded permitted limits within $range range" },
        { 7509, "Access denied, sending domain [$SenderDomain] does not pass DMARC verification and has a DMARC policy of reject" },
        { 7510, "Access denied, does not accept email over IPv6" },
        { 7511, "Access denied, banned sender" },
        { 7512, "Access denied, message must be RFC 5322 section 3.6.2 compliant" },
        { 7513, "Service unavailable, Client host [$ConnectingIP] blocked by $recipientDomain using Customer Block list (AS16012607)" },
        { 7606, "Access denied, banned sending IP [IP1.IP2.IP3.IP4]" }, // 5.7.606-649
        { 7703, "Your message can't be delivered because one or more recipients are blocked by your organization's tenant recipient block policy" },
        { 7705, "Access denied, tenant has exceeded" },
        { 7708, "Access denied, traffic not accepted from this IP" },
        { 7750, "Service unavailable. Client blocked from sending from unregistered domains" },
        { 7850, "Access denied, please try again later" },  // 4.7.850-899
        { 0350, "Generic error, x-dg-ref header is too long, or Requested action not taken: policy violation detected (AS345)" },  // 4.7.850-899
    };

Will this work in a PHP and mySQL website?

I am happy to see something modern that is available for bounce processing. Most products haven't been touched for years. I didn't see anything in the readme file about PHP, so can you let me know?

Thank you.

FileLoadException when using MailKit/MimeKit 1.16.1

Hi, I get the following runtime exception when using the 1.0.3 NuGet version with MailKit/MimeKit 1.16.1.

FileLoadException - Could not load file or assembly 'MimeKit, Version=1.2.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Could you please give some hints about this dependency issue?

Parsing extended status codes

I got extended delivery status code which crashes detector.
Action: failed
Status: 5.7.133
Diagnostic-Code: smtp;550 5.7.133 RESOLVER.RST.SenderNotAuthenticatedForGroup; authentication required; Delivery restriction check failed because the sender was not authenticated when sending to this group

I propose this to fix an issue:

    private static BounceStatus ParseBounceStatus(string statusCode, IDictionary<int, string> statusCodes)
    {
        var value = int.Parse(statusCode);
        if (statusCodes.ContainsKey(value))
            return new BounceStatus(value, statusCodes[value]);
        else
            return new BounceStatus(value, "");
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.