Subject: | Another spam case |
Another spam detection case.
Patch attached or in gitorious tree:
http://gitorious.org/mail-deliverystatus-bounceparser-fork/mail-
deliverystatus-bounceparser-
fork/commit/89be3a5695039f0a930202ec2d5c0b56f8d7f69f
Subject: | 0001-Add-another-spam-detection-case.patch |
From 89be3a5695039f0a930202ec2d5c0b56f8d7f69f Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Thu, 3 Mar 2011 17:28:57 +0000
Subject: [PATCH] Add another spam detection case.
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection10.msg | 79 +++++++++++++++++++++++++++++++
t/spam-rejection10.t | 29 +++++++++++
4 files changed, 112 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection10.msg
create mode 100644 t/spam-rejection10.t
diff --git a/MANIFEST b/MANIFEST
index 3f805a4..43e732c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -78,6 +78,7 @@ t/corpus/spam-rejection6.msg
t/corpus/spam-rejection7.msg
t/corpus/spam-rejection8.msg
t/corpus/spam-rejection9.msg
+t/corpus/spam-rejection10.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -140,6 +141,7 @@ t/spam-rejection6.t
t/spam-rejection7.t
t/spam-rejection8.t
t/spam-rejection9.t
+t/spam-rejection10.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 50054b4..f3f19ed 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1026,7 +1026,8 @@ sub _std_reason {
/Message\s+looks\s+like\s+spam/i or
/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
+ /breaches\s+local\s+URIBL\s+policy/i or
+ /Your\s+email\s+had\s+spam-like\s+header\s+contents/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection10.msg b/t/corpus/spam-rejection10.msg
new file mode 100644
index 0000000..79b3c29
--- /dev/null
+++ b/t/corpus/spam-rejection10.msg
@@ -0,0 +1,79 @@
+Delivered-To: automated-bounces+8a670368-4580-11e0-9852-ad185eea71ff@email.example.com
+Received: by 10.151.98.16 with SMTP id a16cs4677ybm;
+ Thu, 3 Mar 2011 02:25:59 -0800 (PST)
+Received: by 10.227.155.11 with SMTP id q11mr734007wbw.130.1299147958355;
+ Thu, 03 Mar 2011 02:25:58 -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 m1si1691210wbc.61.2011.03.03.02.25.56;
+ Thu, 03 Mar 2011 02:25:57 -0800 (PST)
+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 7945F6507EF; Thu, 3 Mar 2011 10:25:56 +0000 (GMT)
+Date: Thu, 3 Mar 2011 10:25:56 +0000 (GMT)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+8A670368-4580-11E0-9852-AD185EEA71FF@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="3B9C565074D.1299147956/admin1.example.co.uk"
+Message-Id: <20110303102556.7945F6507EF@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--3B9C565074D.1299147956/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 sli.example.com[212.98.181.17] said: 550
+ Error: SPAM-ID: h20030701-214001 Your email had spam-like header contents.
+ Please contact your email service provider. (in reply to end of DATA
+ command)
+
+--3B9C565074D.1299147956/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 3B9C565074D
+X-Postfix-Sender: rfc822; automated-bounces+8A670368-4580-11E0-9852-AD185EEA71FF@email.example.com
+Arrival-Date: Thu, 3 Mar 2011 10:25:20 +0000 (GMT)
+
+Final-Recipient: rfc822; john.smith@example.com
+Action: failed
+Status: 5.0.0
+Remote-MTA: dns; sli.example.com
+Diagnostic-Code: smtp; 550 Error: SPAM-ID: h20030701-214001 Your email had
+ spam-like header contents. Please contact your email service provider.
+
+--3B9C565074D.1299147956/admin1.example.co.uk
+Content-Description: Undelivered Message Headers
+Content-Type: text/rfc822-headers
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 3B9C565074D; Thu, 3 Mar 2011 10:25:20 +0000 (GMT)
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_129914792072750"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Thu, 3 Mar 2011 10:25:20 +0000
+From: Fred Bloggs <fred.bloggs@email.example.com>
+Subject: foo
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=8A670368-4580-11E0-9852-AD185EEA71FF>
+To: John Smith <john.smith@example.com>
+Message-Id: <20110303102520.3B9C565074D@admin1.example.co.uk>
+
+--3B9C565074D.1299147956/admin1.example.co.uk--
diff --git a/t/spam-rejection10.t b/t/spam-rejection10.t
new file mode 100644
index 0000000..5f0d4e7
--- /dev/null
+++ b/t/spam-rejection10.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-rejection10.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