Subject: | Yet another spam case |
Yet another spam case.
Attached or gitorious at https://gitorious.org/mail-deliverystatus-
bounceparser-fork/mail-deliverystatus-bounceparser-
fork/commit/f409f53a7a995b80487267ddb9fe12f4111bfe16
Subject: | 0001-Yet-another-spam-detection-case.patch |
From f409f53a7a995b80487267ddb9fe12f4111bfe16 Mon Sep 17 00:00:00 2001
From: Michael Stevens <mstevens@etla.org>
Date: Mon, 1 Aug 2011 15:24:20 +0100
Subject: [PATCH] Yet another spam detection case
---
MANIFEST | 2 +
lib/Mail/DeliveryStatus/BounceParser.pm | 3 +-
t/corpus/spam-rejection16.msg | 100 +++++++++++++++++++++++++++++++
t/spam-rejection16.t | 29 +++++++++
4 files changed, 133 insertions(+), 1 deletions(-)
create mode 100644 t/corpus/spam-rejection16.msg
create mode 100644 t/spam-rejection16.t
diff --git a/MANIFEST b/MANIFEST
index 5d446d1..6059458 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -84,6 +84,7 @@ t/corpus/spam-rejection12.msg
t/corpus/spam-rejection13.msg
t/corpus/spam-rejection14.msg
t/corpus/spam-rejection15.msg
+t/corpus/spam-rejection16.msg
t/corpus/spam-rejection-uribl.msg
t/corpus/spam-with-badly-parsed-email.msg
t/corpus/spam-with-image.msg
@@ -153,6 +154,7 @@ t/spam-rejection12.t
t/spam-rejection13.t
t/spam-rejection14.t
t/spam-rejection15.t
+t/spam-rejection16.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 c2d7887..11dd61d 100644
--- a/lib/Mail/DeliveryStatus/BounceParser.pm
+++ b/lib/Mail/DeliveryStatus/BounceParser.pm
@@ -1033,7 +1033,8 @@ sub _std_reason {
/Denied\s+due\s+to\s+spam\s+list/i or
/appears\s+to\s+be\s+unsolicited/i or
/antispam\s+checks/i or
- /Probable\s+Spam/i
+ /Probable\s+Spam/i or
+ /ESETS_SMTP\s+\(spam\)/i
) {
return "spam";
}
diff --git a/t/corpus/spam-rejection16.msg b/t/corpus/spam-rejection16.msg
new file mode 100644
index 0000000..38271c3
--- /dev/null
+++ b/t/corpus/spam-rejection16.msg
@@ -0,0 +1,100 @@
+Delivered-To: automated-bounces+d5b48520-b83a-11e0-a9d4-f6c9a663b7ab@email.example.com
+Received: by 10.142.214.7 with SMTP id m7cs191725wfg;
+ Wed, 27 Jul 2011 03:26:28 -0700 (PDT)
+Received: by 10.223.27.71 with SMTP id h7mr8095002fac.142.1311762386869;
+ Wed, 27 Jul 2011 03:26:26 -0700 (PDT)
+Return-Path: <>
+Received: from mx2.mail.sample.net (smtp-02.mail.sample.net [213.81.185.95])
+ by mx.google.com with ESMTP id d24si228646fak.82.2011.07.27.03.26.26;
+ Wed, 27 Jul 2011 03:26:26 -0700 (PDT)
+Received-SPF: pass (google.com: domain of mx2.mail.sample.net designates 213.81.185.95 as permitted sender) client-ip=213.81.185.95;
+Authentication-Results: mx.google.com; spf=pass (google.com: domain of mx2.mail.sample.net designates 213.81.185.95 as permitted sender) smtp.mail=
+Received: by mx2.mail.sample.net (Postfix)
+ id EA112C419F; Wed, 27 Jul 2011 12:26:25 +0200 (CEST)
+Date: Wed, 27 Jul 2011 12:26:25 +0200 (CEST)
+From: MAILER-DAEMON@sample.net (Mail Delivery System)
+Subject: Undelivered Mail Returned to Sender
+To: automated-bounces+D5B48520-B83A-11E0-A9D4-F6C9A663B7AB@email.example.com
+Auto-Submitted: auto-replied
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status;
+ boundary="2EE81C425C.1311762385/mx2.mail.sample.net"
+Message-Id: <20110727102625.EA112C419F@mx2.mail.sample.net>
+
+This is a MIME-encapsulated message.
+
+--2EE81C425C.1311762385/mx2.mail.sample.net
+Content-Description: Notification
+Content-Type: text/plain; charset=us-ascii
+
+This is the mail system at host mx2.mail.sample.net.
+
+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@sample.net>: host 127.0.0.1[127.0.0.1] said: 550 Rejected by ESETS_SMTP
+ (spam) (in reply to end of DATA command)
+
+--2EE81C425C.1311762385/mx2.mail.sample.net
+Content-Description: Delivery report
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns; mx2.mail.sample.net
+X-Postfix-Queue-ID: 2EE81C425C
+X-Postfix-Sender: rfc822; automated-bounces+D5B48520-B83A-11E0-A9D4-F6C9A663B7AB@email.example.com
+Arrival-Date: Wed, 27 Jul 2011 12:26:17 +0200 (CEST)
+
+Final-Recipient: rfc822; john.smith@sample.net
+Original-Recipient: rfc822;john.smith@sample.net
+Action: failed
+Status: 5.0.0
+Remote-MTA: dns; 127.0.0.1
+Diagnostic-Code: smtp; 550 Rejected by ESETS_SMTP (spam)
+
+--2EE81C425C.1311762385/mx2.mail.sample.net
+Content-Description: Undelivered Message
+Content-Type: message/rfc822
+
+Return-Path: <automated-bounces+D5B48520-B83A-11E0-A9D4-F6C9A663B7AB@email.example.com>
+Received: from admin1.example.co.uk (admin1.example.co.uk [94.236.45.212])
+ by mx2.mail.sample.net (Postfix) with ESMTP id 2EE81C425C
+ for <john.smith@sample.net>; Wed, 27 Jul 2011 12:26:17 +0200 (CEST)
+Received: by admin1.example.co.uk (Postfix, from userid 507)
+ id 6CF0F651084; Wed, 27 Jul 2011 11:26:05 +0100 (BST)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.example.com;
+ s=default10; t=1311762365;
+ bh=qkRhJWf9zAc6wFeNsqcFb4qL7rOFhNOGo0QP5bY9Imw=;
+ h=MIME-Version:Content-Transfer-Encoding:Content-Type:Date:From:
+ Subject:List-Unsubscribe:To:Message-Id;
+ b=It1+SE+0Sn3WZ2vpu3M5RoOld2zh1xIy0bYSpnuSNtgA747Fk1Z7Oe8/It6Z7IA5l
+ WpV8o9SumNrkAPTGLGxxOtE/OrU+2j9PC14KANHts7Rq/E6RP581c1qvpRuaYKKAsl
+ sHmskMSY/ml54DludZrT0T7WFs4+vIw7a5cSVlfA=
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/related; boundary="_----------=_131176236524422835"
+X-Mailer: MIME::Lite 3.027 (F2.78; T1.31; A2.07; B3.13; Q3.13)
+Date: Wed, 27 Jul 2011 11:26:05 +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=D5B48520-B83A-11E0-A9D4-F6C9A663B7AB>
+To: john smith <john.smith@sample.net>
+Message-Id: <20110727102605.6CF0F651084@admin1.example.co.uk>
+
+This is a multi-part message in MIME format.
+
+--_----------=_131176236524422835
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html
+
+HTML
+
+--2EE81C425C.1311762385/mx2.mail.sample.net--
diff --git a/t/spam-rejection16.t b/t/spam-rejection16.t
new file mode 100644
index 0000000..8563844
--- /dev/null
+++ b/t/spam-rejection16.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-rejection16.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