CC: | michael.stevens [...] dianomi.com,michael.smith [...] dianomi.com |
Subject: | Another spam case |
Another spam detection case.
git patch attached.
Patch in gitorious tree at:
http://gitorious.org/mail-deliverystatus-bounceparser-fork/mail-
deliverystatus-bounceparser-
fork/commit/03048253b79b2c26144de2498241b72cf09f0951
Subject: | 0001-Add-another-spam-detection-case.patch |
From 03048253b79b2c26144de2498241b72cf09f0951 Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Thu, 24 Mar 2011 17:50:00 +0000
Subject: [PATCH] Add another spam detection case.
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection11.msg | 92 +++++++++++++++++++++++++++++++
t/spam-rejection11.t | 29 ++++++++++
4 files changed, 125 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection11.msg
create mode 100644 t/spam-rejection11.t
diff --git a/MANIFEST b/MANIFEST
index 43e732c..1bcca9c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -79,6 +79,7 @@ t/corpus/spam-rejection7.msg
t/corpus/spam-rejection8.msg
t/corpus/spam-rejection9.msg
t/corpus/spam-rejection10.msg
+t/corpus/spam-rejection11.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -142,6 +143,7 @@ t/spam-rejection7.t
t/spam-rejection8.t
t/spam-rejection9.t
t/spam-rejection10.t
+t/spam-rejection11.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 f3f19ed..bdb49f0 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1027,7 +1027,8 @@ sub _std_reason {
/Message\s+content\s+rejected,\s+UBE/i or
/Blocked\s+using\s+spam\s+pattern/i or
/breaches\s+local\s+URIBL\s+policy/i or
- /Your\s+email\s+had\s+spam-like\s+header\s+contents/i
+ /Your\s+email\s+had\s+spam-like\s+header\s+contents/i or
+ /detected\s+as\s+spam/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection11.msg b/t/corpus/spam-rejection11.msg
new file mode 100644
index 0000000..d5ddf8b
--- /dev/null
+++ b/t/corpus/spam-rejection11.msg
@@ -0,0 +1,92 @@
+Delivered-To: automated-bounces+f2f90b2c-552c-11e0-98d5-ff80b93d4449@email.example.com
+Received: by 10.236.102.178 with SMTP id d38cs11226yhg;
+ Wed, 23 Mar 2011 02:07:28 -0700 (PDT)
+Received: by 10.216.202.147 with SMTP id d19mr6125408weo.23.1300871247137;
+ Wed, 23 Mar 2011 02:07:27 -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 n33si14629042wei.194.2011.03.23.02.07.25;
+ Wed, 23 Mar 2011 02:07:26 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for 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: best guess record for domain of admin1.example.co.uk designates 94.236.45.212 as permitted sender) smtp.mail=
+Received: by admin1.example.co.uk (Postfix)
+ id 1B22C650FBF; Wed, 23 Mar 2011 09:07:25 +0000 (GMT)
+Date: Wed, 23 Mar 2011 09:07:25 +0000 (GMT)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+F2F90B2C-552C-11E0-98D5-FF80B93D4449@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="72F03650F6E.1300871245/admin1.example.co.uk"
+Message-Id: <20110323090725.1B22C650FBF@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--72F03650F6E.1300871245/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@example.net>: host mx0.123-reg.co.uk[94.136.40.150] said: 550
+ ATLAS(2503): Your email was detected as spam. (RCPTs: john@example.net)
+ (in reply to end of DATA command)
+
+--72F03650F6E.1300871245/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 72F03650F6E
+X-Postfix-Sender: rfc822; automated-bounces+F2F90B2C-552C-11E0-98D5-FF80B93D4449@email.example.com
+Arrival-Date: Wed, 23 Mar 2011 09:07:16 +0000 (GMT)
+
+Final-Recipient: rfc822; john@example.net
+Action: failed
+Status: 5.0.0
+Remote-MTA: dns; mx0.123-reg.co.uk
+Diagnostic-Code: smtp; 550 ATLAS(2503): Your email was detected as spam.
+ (RCPTs: john@example.net)
+
+--72F03650F6E.1300871245/admin1.example.co.uk
+Content-Description: Undelivered Message
+Content-Type: message/rfc822
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 72F03650F6E; Wed, 23 Mar 2011 09:07:16 +0000 (GMT)
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_13008712364437334"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Wed, 23 Mar 2011 09:07:16 +0000
+From: Fred Bloggs <fred.bloggs@email.example.com>
+Subject: foo
+X-Campaignid: example20100819.2
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=F2F90B2C-552C-11E0-98D5-FF80B93D4449>
+To: John Smith <john@example.net>
+Message-Id: <20110323090716.72F03650F6E@admin1.example.co.uk>
+
+This is a multi-part message in MIME format.
+
+--_----------=_13008712364437334
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html
+
+HTML
+
+--_----------=_13008712364437334--
+
+
+--72F03650F6E.1300871245/admin1.example.co.uk--
diff --git a/t/spam-rejection11.t b/t/spam-rejection11.t
new file mode 100644
index 0000000..d73b7eb
--- /dev/null
+++ b/t/spam-rejection11.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-rejection11.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.1