Subject: | new spam case |
new spam case
Patch attached or in gitorious:
https://gitorious.org/mail-deliverystatus-bounceparser-fork/mail-
deliverystatus-bounceparser-
fork/commit/ee1e136098967aaaf99dd96c674cd24d592236cc
Subject: | 0001-Add-new-spam-case.patch |
From ee1e136098967aaaf99dd96c674cd24d592236cc Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Fri, 21 Oct 2011 16:59:47 +0100
Subject: [PATCH] Add new spam case
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection22.msg | 99 +++++++++++++++++++++++++++++++
t/spam-rejection22.t | 29 +++++++++
4 files changed, 132 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection22.msg
create mode 100644 t/spam-rejection22.t
diff --git a/MANIFEST b/MANIFEST
index 8069ee8..8f1575c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -90,6 +90,7 @@ t/corpus/spam-rejection18.msg
t/corpus/spam-rejection19.msg
t/corpus/spam-rejection20.msg
t/corpus/spam-rejection21.msg
+t/corpus/spam-rejection22.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -165,6 +166,7 @@ t/spam-rejection18.t
t/spam-rejection19.t
t/spam-rejection20.t
t/spam-rejection21.t
+t/spam-rejection22.t
t/spam-rejection-uribl.t
t/spam-with-image.t
t/spamassassin.t
diff --git a/lib/Mail/DeliveryStatus/BounceParser.pm b/lib/Mail/DeliveryStatus/BounceParser.pm
index d6059a6..79055c7 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1039,7 +1039,8 @@ sub _std_reason {
/Spam\s+score\s+\(\S+\)\s+too\s+high/i or
/matches\s+a\s+profile\s+the\s+Internet\s+community\s+may\s+consider\s+spam/i or
/accepted\s+due\s+to\s+spam\s+filter/i or
- /content\s+filter\s+rejection/i
+ /content\s+filter\s+rejection/i or
+ /using\s+a\s+mass\s+mailer/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection22.msg b/t/corpus/spam-rejection22.msg
new file mode 100644
index 0000000..4db4103
--- /dev/null
+++ b/t/corpus/spam-rejection22.msg
@@ -0,0 +1,99 @@
+Delivered-To: automated-bounces+64dd736c-fb14-11e0-8fd4-e50a16514328@email.example.com
+Received: by 10.229.184.67 with SMTP id cj3cs207864qcb;
+ Thu, 20 Oct 2011 05:30:20 -0700 (PDT)
+Received: by 10.216.138.221 with SMTP id a71mr4186633wej.102.1319113819652;
+ Thu, 20 Oct 2011 05:30:19 -0700 (PDT)
+Return-Path: <>
+Received: from admin1.example.co.uk (admin1.example.co.uk. [94.236.45.212])
+ by mx.google.com with ESMTP id z32si6804375weq.133.2011.10.20.05.30.19;
+ Thu, 20 Oct 2011 05:30:19 -0700 (PDT)
+Received-SPF: pass (google.com: domain of admin1.example.co.uk designates 94.236.45.212 as permitted sender) client-ip=94.236.45.212;
+Authentication-Results: mx.google.com; spf=pass (google.com: domain of admin1.example.co.uk designates 94.236.45.212 as permitted sender) smtp.mail=
+Received: by admin1.example.co.uk (Postfix)
+ id 40B8865108D; Thu, 20 Oct 2011 13:30:19 +0100 (BST)
+Date: Thu, 20 Oct 2011 13:30:19 +0100 (BST)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+64DD736C-FB14-11E0-8FD4-E50A16514328@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="4B94C65106A.1319113819/admin1.example.co.uk"
+Message-Id: <20111020123019.40B8865108D@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--4B94C65106A.1319113819/admin1.example.co.uk
+Content-Description: Notification
+Content-Type: text/plain; charset=us-ascii
+
+This is the mail system at host admin1.example.co.uk.
+
+I'm sorry to have to inform you that your message could not
+be delivered to one or more recipients. It's attached below.
+
+For further assistance, please send mail to <postmaster>
+
+If you do so, please include this problem report. You can
+delete your own text from the attached returned message.
+
+ The mail system
+
+<fred@example.net>: host a.mx.example.net[213.162.120.70] said: 550
+ 5.7.1 You're using a mass mailer, therefore you're bounced. (in reply to
+ end of DATA command)
+
+--4B94C65106A.1319113819/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 4B94C65106A
+X-Postfix-Sender: rfc822; automated-bounces+64DD736C-FB14-11E0-8FD4-E50A16514328@email.example.com
+Arrival-Date: Thu, 20 Oct 2011 13:09:43 +0100 (BST)
+
+Final-Recipient: rfc822; fred@example.net
+Action: failed
+Status: 5.7.1
+Remote-MTA: dns; a.mx.example.net
+Diagnostic-Code: smtp; 550 5.7.1 You're using a mass mailer, therefore you're
+ bounced.
+
+--4B94C65106A.1319113819/admin1.example.co.uk
+Content-Description: Undelivered Message
+Content-Type: message/rfc822
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 4B94C65106A; Thu, 20 Oct 2011 13:09:43 +0100 (BST)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.example.com;
+ s=default10; t=1319112583;
+ bh=nVOidzxGwLzWAOSa6+LP6YjsuvPGLgxKXHz6gSEhAN0=;
+ h=MIME-Version:Content-Transfer-Encoding:Content-Type:Date:From:
+ Subject:List-Unsubscribe:To:Message-Id;
+ b=zB3lH1I+AIN4GuYta1GZ6zrgor5AnEToTuTPFwpr0oR6WCmPkohZysraPtfF6JTp1
+ LzcbD7p9+qpVqtpQUhnGBZABI0AwNjdZBg7Bjf8GUYSl3vVCSiqKsKUe3OMOrUBCo2
+ 4I/5g7Z0paylPkm26sESl1YNrSWKxj5j1y6dbu5g=
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_1319112583110380"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Thu, 20 Oct 2011 13:09:43 +0100
+From: John Smith <john.smith@email.example.com>
+Subject: foo
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=64DD736C-FB14-11E0-8FD4-E50A16514328>
+To: fred bloggs <fred@example.net>
+Message-Id: <20111020120943.4B94C65106A@admin1.example.co.uk>
+
+This is a multi-part message in MIME format.
+
+--_----------=_1319112583110380
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html
+
+HTML
+
+--_----------=_1319112583110380--
+
+
+--4B94C65106A.1319113819/admin1.example.co.uk--
diff --git a/t/spam-rejection22.t b/t/spam-rejection22.t
new file mode 100644
index 0000000..6a9fa30
--- /dev/null
+++ b/t/spam-rejection22.t
@@ -0,0 +1,29 @@
+#!perl -wT
+use strict;
+
+use Test::More tests => 3;
+
+use Mail::DeliveryStatus::BounceParser;
+
+# FH because we're being backcompat to pre-lexical
+sub readfile {
+ my $fn = shift;
+ open FH, "$fn" or die $!;
+ local $/;
+ my $text = <FH>;
+ close FH;
+ return $text;
+}
+
+my $message = readfile('t/corpus/spam-rejection22.msg');
+
+my $bounce = Mail::DeliveryStatus::BounceParser->new($message);
+
+isa_ok($bounce, 'Mail::DeliveryStatus::BounceParser');
+ok($bounce->is_bounce, "This is a bounce");
+
+my ($report) = $bounce->reports;
+
+my $std_reason = $report->get("std_reason");
+
+is($std_reason, "spam", "std reason is spam");
--
1.7.5.4