Subject: | Yet another spam case |
Yet more spam.
Attached or
https://gitorious.org/mail-deliverystatus-bounceparser-fork/mail-
deliverystatus-bounceparser-
fork/commit/2a5d8292aaf8f56e738f94041645b1779a90277f
Subject: | 0001-Yet-again-a-spam-detection-case.patch |
From 2a5d8292aaf8f56e738f94041645b1779a90277f Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Mon, 1 Aug 2011 15:50:00 +0100
Subject: [PATCH] Yet again a spam detection case.
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection17.msg | 98 +++++++++++++++++++++++++++++++
t/spam-rejection17.t | 29 +++++++++
4 files changed, 131 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection17.msg
create mode 100644 t/spam-rejection17.t
diff --git a/MANIFEST b/MANIFEST
index 6059458..34cf580 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -85,6 +85,7 @@ t/corpus/spam-rejection13.msg
t/corpus/spam-rejection14.msg
t/corpus/spam-rejection15.msg
t/corpus/spam-rejection16.msg
+t/corpus/spam-rejection17.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -155,6 +156,7 @@ t/spam-rejection13.t
t/spam-rejection14.t
t/spam-rejection15.t
t/spam-rejection16.t
+t/spam-rejection17.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 11dd61d..45b81a3 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1034,7 +1034,8 @@ sub _std_reason {
/appears\s+to\s+be\s+unsolicited/i or
/antispam\s+checks/i or
/Probable\s+Spam/i or
- /ESETS_SMTP\s+\(spam\)/i
+ /ESETS_SMTP\s+\(spam\)/i or
+ /this\s+message\s+appears\s+to\s+be\s+spam/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection17.msg b/t/corpus/spam-rejection17.msg
new file mode 100644
index 0000000..2f6b2f0
--- /dev/null
+++ b/t/corpus/spam-rejection17.msg
@@ -0,0 +1,98 @@
+Delivered-To: automated-bounces+128a4236-b8fa-11e0-a28d-d685a71a8688@email.example.com
+Received: by 10.142.214.7 with SMTP id m7cs233389wfg;
+ Thu, 28 Jul 2011 02:15:10 -0700 (PDT)
+Received: by 10.14.9.196 with SMTP id 44mr360398eet.122.1311844509619;
+ Thu, 28 Jul 2011 02:15:09 -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 v34si1494504weq.40.2011.07.28.02.15.07;
+ Thu, 28 Jul 2011 02:15:08 -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 D04B06510DE; Thu, 28 Jul 2011 10:15:07 +0100 (BST)
+Date: Thu, 28 Jul 2011 10:15:07 +0100 (BST)
+From: MAILER-DAEMON@admin1.example.co.uk (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+128A4236-B8FA-11E0-A28D-D685A71A8688@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="5C5356510B6.1311844507/admin1.example.co.uk"
+Message-Id: <20110728091507.D04B06510DE@admin1.example.co.uk>
+
+This is a MIME-encapsulated message.
+
+--5C5356510B6.1311844507/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@sample.com>: host mail.example2.co.uk[83.243.101.206] said: 554 Sorry, this
+ message appears to be spam (#5.6.0) (in reply to end of DATA command)
+
+--5C5356510B6.1311844507/admin1.example.co.uk
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; admin1.example.co.uk
+X-Postfix-Queue-ID: 5C5356510B6
+X-Postfix-Sender: rfc822; automated-bounces+128A4236-B8FA-11E0-A28D-D685A71A8688@email.example.com
+Arrival-Date: Thu, 28 Jul 2011 10:15:01 +0100 (BST)
+
+Final-Recipient: rfc822; john@sample.com
+Action: failed
+Status: 5.0.0
+Remote-MTA: dns; mail.example2.co.uk
+Diagnostic-Code: smtp; 554 Sorry, this message appears to be spam (#5.6.0)
+
+--5C5356510B6.1311844507/admin1.example.co.uk
+Content-Description: Undelivered Message
+Content-Type: message/rfc822
+
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 5C5356510B6; Thu, 28 Jul 2011 10:15:01 +0100 (BST)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.example.com;
+ s=default10; t=1311844501;
+ bh=kgnL9Eq+aWBe7me/syQfYVc3zZUObSuApuu89ofUm5I=;
+ h=MIME-Version:Content-Transfer-Encoding:Content-Type:Date:From:
+ Subject:List-Unsubscribe:To:Message-Id;
+ b=cHbcG5UBtbpE4LOZ/YjBo9dGvbngV6vD23p6L4GWRxWWrgbVwIQFOK6LUg4YCYioM
+ 20iwNDVgN4LmryOfb7O9FLBURnnlkv245NVnsiy6BHXZIbpdSkDF7NVy4A4Q9BwDnF
+ 01Ek2+AWlxF309yXVv0LS8mmWEjESnEwAx1dKfRI=
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_131184450117109368"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Thu, 28 Jul 2011 10:15:01 +0100
+From: Fred Bloggs <fred.bloggs@email.example.com>
+Subject: foo
+X-Campaignid: example20100819.2
+List-Unsubscribe: <http://www.exampleoffers.co.uk/unsubscribe.epl?uuid=128A4236-B8FA-11E0-A28D-D685A71A8688>
+To: John Smith <john@sample.com>
+Message-Id: <20110728091501.5C5356510B6@admin1.example.co.uk>
+
+This is a multi-part message in MIME format.
+
+--_----------=_131184450117109368
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html
+
+HTML
+
+--_----------=_131184450117109368--
+
+
+--5C5356510B6.1311844507/admin1.example.co.uk--
diff --git a/t/spam-rejection17.t b/t/spam-rejection17.t
new file mode 100644
index 0000000..f691639
--- /dev/null
+++ b/t/spam-rejection17.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-rejection17.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