Subject: | Another spam case |
Another spam case.
Patch attached, or https://gitorious.org/mail-deliverystatus-
bounceparser-fork/mail-deliverystatus-bounceparser-
fork/commit/56dd1b7e0f68efcf30860848aa6f998ed3848b2e
Subject: | 0001-Another-spam-detection-case.patch |
From 56dd1b7e0f68efcf30860848aa6f998ed3848b2e Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Mon, 1 Aug 2011 14:30:10 +0100
Subject: [PATCH] Another spam detection case.
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection15.msg | 100 +++++++++++++++++++++++++++++++
t/spam-rejection15.t | 29 +++++++++
4 files changed, 133 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection15.msg
create mode 100644 t/spam-rejection15.t
diff --git a/MANIFEST b/MANIFEST
index d5b0bd0..5d446d1 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -83,6 +83,7 @@ t/corpus/spam-rejection11.msg
t/corpus/spam-rejection12.msg
t/corpus/spam-rejection13.msg
t/corpus/spam-rejection14.msg
+t/corpus/spam-rejection15.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -151,6 +152,7 @@ t/spam-rejection11.t
t/spam-rejection12.t
t/spam-rejection13.t
t/spam-rejection14.t
+t/spam-rejection15.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 afc21de..c2d7887 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1032,7 +1032,8 @@ sub _std_reason {
/detected\s+as\s+spam/i or
/Denied\s+due\s+to\s+spam\s+list/i or
/appears\s+to\s+be\s+unsolicited/i or
- /antispam\s+checks/i
+ /antispam\s+checks/i or
+ /Probable\s+Spam/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection15.msg b/t/corpus/spam-rejection15.msg
new file mode 100644
index 0000000..d3c9814
--- /dev/null
+++ b/t/corpus/spam-rejection15.msg
@@ -0,0 +1,100 @@
+Delivered-To: automated-bounces+13a16098-bab5-11e0-b15e-be5c69b90385@email.example.com
+Received: by 10.142.230.13 with SMTP id c13cs10840wfh;
+ Sat, 30 Jul 2011 07:06:14 -0700 (PDT)
+Received: from mr.google.com ([10.227.58.130])
+ by 10.227.58.130 with SMTP id g2mr4677769wbh.44.1312034774006 (num_hops = 1);
+ Sat, 30 Jul 2011 07:06:14 -0700 (PDT)
+Received: by 10.227.58.130 with SMTP id g2mr3601178wbh.44.1312034773040;
+ Sat, 30 Jul 2011 07:06:13 -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 fm12si6029405wbb.50.2011.07.30.07.06.11;
+ Sat, 30 Jul 2011 07:06:11 -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 4774E6510F7; Sat, 30 Jul 2011 15:06:11 +0100 (BST)
+Date: Sat, 30 Jul 2011 15:06:11 +0100 (BST)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+13A16098-BAB5-11E0-B15E-BE5C69B90385@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="40F186510F5.1312034771/admin1.example.co.uk" Message-Id: <20110730140611.4774E6510F7@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--40F186510F5.1312034771/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
+
+<gf@sample.co.uk>: host mailhost.example2.co.uk[88.208.238.130] said: 550
+ Probable Spam (in reply to end of DATA command)
+
+--40F186510F5.1312034771/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 40F186510F5
+X-Postfix-Sender: rfc822; automated-bounces+13A16098-BAB5-11E0-B15E-BE5C69B90385@email.example.com
+Arrival-Date: Sat, 30 Jul 2011 15:06:10 +0100 (BST)
+
+Final-Recipient: rfc822; gf@sample.co.uk
+Action: failed
+Status: 5.0.0
+Remote-MTA: dns; mailhost.example2.co.uk
+Diagnostic-Code: smtp; 550 Probable Spam
+
+--40F186510F5.1312034771/admin1.example.co.uk
+Content-Description: Undelivered Message
+Content-Type: message/rfc822
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 40F186510F5; Sat, 30 Jul 2011 15:06:10 +0100 (BST)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.example.com;
+ s=default10; t=1312034770;
+ bh=YhIgAd9h+zPrVAdaRozHBFzTKR7pEZ9DCmeceTMYjnM=;
+ h=MIME-Version:Content-Transfer-Encoding:Content-Type:Date:From:
+ Subject:List-Unsubscribe:To:Message-Id;
+ b=Llt2w50Y531qpYGT4W2k8ByIukLB1KyvRYRRqvAUQlGC7nF4v10OQ3JJ1xyTrelDI
+ nUrcAg6zmbj4rIfHALg4UUwwVHMmKT+ewzKRJNCmUqc+LYvyuKgtLOEdbexkMFSe5A
+ QeDxaqro0RQkMflhX+PA3BQm2HxGX3whjTe51DfY=
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_131203477022648100"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Sat, 30 Jul 2011 15:06:10 +0100
+From: Fred Bloggs <fred.bloggs@email.example.com>
+Subject: subject
+X-Campaignid: example20100819.2
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=13A16098-BAB5-11E0-B15E-BE5C69B90385>
+To: John Sample <gf@sample.co.uk>
+Message-Id: <20110730140610.40F186510F5@admin1.example.co.uk>
+
+This is a multi-part message in MIME format.
+
+--_----------=_131203477022648100
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html
+
+HTML
+
+--_----------=_131203477022648100--
+
+
+--40F186510F5.1312034771/admin1.example.co.uk--
diff --git a/t/spam-rejection15.t b/t/spam-rejection15.t
new file mode 100644
index 0000000..25efdc3
--- /dev/null
+++ b/t/spam-rejection15.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-rejection15.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.4.1