CC: | michael.stevens [...] dianomi.com, michael.smith [...] dianomi.com |
Subject: | Another spam case |
Another spam case.
Patch attached or in gitorious.
Subject: | 0001-Another-spam-case.patch |
From 044b51aa575d8ce32725956841f7fa33e91cc4fe Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Mon, 28 Nov 2011 14:29:05 +0000
Subject: [PATCH] Another spam case
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection27.msg | 94 +++++++++++++++++++++++++++++++
t/spam-rejection27.t | 29 ++++++++++
4 files changed, 127 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection27.msg
create mode 100644 t/spam-rejection27.t
diff --git a/MANIFEST b/MANIFEST
index 4d8ba0e..2d6bf33 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -96,6 +96,7 @@ t/corpus/spam-rejection23.msg
t/corpus/spam-rejection24.msg
t/corpus/spam-rejection25.msg
t/corpus/spam-rejection26.msg
+t/corpus/spam-rejection26.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -177,6 +178,7 @@ t/spam-rejection23.t
t/spam-rejection24.t
t/spam-rejection25.t
t/spam-rejection26.t
+t/spam-rejection27.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 52d13b1..130e542 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1043,7 +1043,8 @@ sub _std_reason {
/Spam\s+email/i or
/Spam\s+content\s+matched/i or
(/CONTENT\s+REJECT/i and /dspam\s+check/i) or
- /this\s+email\s+is\s+spam/i
+ /this\s+email\s+is\s+spam/i or
+ /rejected\s+as\s+spam/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection27.msg b/t/corpus/spam-rejection27.msg
new file mode 100644
index 0000000..04baf31
--- /dev/null
+++ b/t/corpus/spam-rejection27.msg
@@ -0,0 +1,94 @@
+Delivered-To: automated-bounces+8d8bebc8-1076-11e1-972a-8c90f9ecf27a@email.example.com
+Received: by 10.142.214.11 with SMTP id m11cs80737wfg;
+ Wed, 16 Nov 2011 09:15:31 -0800 (PST)
+Received: by 10.180.7.97 with SMTP id i1mr36578752wia.23.1321463728706;
+ Wed, 16 Nov 2011 09:15:28 -0800 (PST)
+Return-Path: <>
+Received: from admin1.example.co.uk (admin1.example.co.uk. [94.236.45.212])
+ by mx.google.com with ESMTP id b47si14798663wed.68.2011.11.16.09.15.28;
+ Wed, 16 Nov 2011 09:15:28 -0800 (PST)
+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 DE411651153; Wed, 16 Nov 2011 17:15:27 +0000 (GMT)
+Date: Wed, 16 Nov 2011 17:15:27 +0000 (GMT)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+8D8BEBC8-1076-11E1-972A-8C90F9ECF27A@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="7B08B651150.1321463727/admin1.example.co.uk"
+Message-Id: <20111116171527.DE411651153@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--7B08B651150.1321463727/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
+
+<john.smith@example.com>: host
+ example.com.inbound10.example2.net[208.65.145.3] said: 550 Backend
+ Replied [4afe3ce4.0.668380.00-2282.869002.p01c12m092.example2.net]: 5.7.1
+ Message rejected as spam by Conten (in reply to end of DATA command)
+
+--7B08B651150.1321463727/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 7B08B651150
+X-Postfix-Sender: rfc822; automated-bounces+8D8BEBC8-1076-11E1-972A-8C90F9ECF27A@email.example.com
+Arrival-Date: Wed, 16 Nov 2011 17:15:16 +0000 (GMT)
+
+Final-Recipient: rfc822; john.smith@example.com
+Action: failed
+Status: 5.0.0
+Remote-MTA: dns; example.com.inbound10.example2.net
+Diagnostic-Code: smtp; 550 Backend Replied
+ [4afe3ce4.0.668380.00-2282.869002.p01c12m092.example2.net]: 5.7.1 Message
+ rejected as spam by Conten
+
+--7B08B651150.1321463727/admin1.example.co.uk
+Content-Description: Undelivered Message
+Content-Type: message/rfc822
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 7B08B651150; Wed, 16 Nov 2011 17:15:16 +0000 (GMT)
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_132146371627309101"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Wed, 16 Nov 2011 17:15:16 +0000
+From: Fred Bloggs <fred.bloggs@email.example.com>
+Subject: test
+X-Campaignid: example20100129.2
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=8D8BEBC8-1076-11E1-972A-8C90F9ECF27A>
+To: John Smith <john.smith@example.com>
+Message-Id: <20111116171516.7B08B651150@admin1.example.co.uk>
+
+This is a multi-part message in MIME format.
+
+--_----------=_132146371627309101
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html
+
+HTML
+
+--_----------=_132146371627309101--
+
+
+--7B08B651150.1321463727/admin1.example.co.uk--
diff --git a/t/spam-rejection27.t b/t/spam-rejection27.t
new file mode 100644
index 0000000..1d76e24
--- /dev/null
+++ b/t/spam-rejection27.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-rejection27.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.2.5