tangofoxtrot-tmail_bouncer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,7 +76,8 @@ module TmailBouncer
76
76
  end
77
77
 
78
78
  def original_recipient
79
- @original_recipient ||= self.status_info["Final-Recipient"].to_s.gsub(%r%Final-Recipient: %i,"").gsub(%r%rfc822;%i,"").strip
79
+ recip_key = self.status_info["Final-Recipient"] || self.status_info["Final-recipient"]
80
+ @original_recipient ||= recip_key.to_s.gsub(%r%Final-Recipient: %i,"").gsub(%r%rfc822;%i,"").strip
80
81
  end
81
82
 
82
83
  def status_info
@@ -0,0 +1,99 @@
1
+ Return-Path: <>
2
+ X-Original-To: joe@example.com
3
+ Delivered-To: joe@example.com
4
+ Received: from vms169133pub.verizon.net (mail.example.com [1.1.1.1])
5
+ by mail.example.com (Postfix) with ESMTP id 6731C1780CB
6
+ for <joe@example.com>; Fri, 5 Jun 2009 06:42:55 -0700 (PDT)
7
+ X-DKIM: Sendmail DKIM Filter v2.4.0 mail.example.com 6731C1780CB
8
+ Received: from vms169133pub.verizon.net ([1.1.1.1] helo=vms169133pub.verizon.net)
9
+ by ASSP.nospam; 5 Jun 2009 06:42:55 -0700
10
+ Received: from process-daemon.vms169133.mailsrvcs.net by
11
+ vms169133.mailsrvcs.net
12
+ (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit))
13
+ id <0KKR00700Q1L4100@vms169133.mailsrvcs.net> for joe@example.com; Fri,
14
+ 05 Jun 2009 08:43:05 -0500 (CDT)
15
+ Received: from vms169133.mailsrvcs.net
16
+ (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit))
17
+ id <0KKR00M9HQ3T8100@vms169133.mailsrvcs.net>; Fri,
18
+ 05 Jun 2009 08:43:05 -0500 (CDT)
19
+ Date: Fri, 05 Jun 2009 08:43:05 -0500 (CDT)
20
+ From: Verizon Online Postmaster <postmaster@verizon.net>
21
+ Subject: Delivery Notification: Delivery has failed
22
+ To: joe@example.com
23
+ Message-id: <1234.1212@example.com>
24
+ MIME-version: 1.0
25
+ Content-type: multipart/report; report-type=delivery-status;
26
+ boundary="Boundary_(ID_i9HI+uq/Ow7SRFDKTB0YAg)"
27
+ X-Assp-Received-RBL: pass
28
+
29
+
30
+ --Boundary_(ID_i9HI+uq/Ow7SRFDKTB0YAg)
31
+ Content-type: text/plain; charset=us-ascii
32
+ Content-language: en-US
33
+
34
+ This report relates to a message you sent with the following header fields:
35
+
36
+ Message-id: <1234.1212@example.com>
37
+ Date: Fri, 05 Jun 2009 06:41:59 -0700
38
+ From: joe@example.com
39
+ To: fred@somewhere.com
40
+ Subject: I like turtles
41
+
42
+ Your message cannot be delivered to the following recipients:
43
+
44
+ Recipient address: fred@somewhere.com
45
+ Original address: fred@somewhere.com
46
+ Reason: Remote SMTP server has rejected address
47
+ Diagnostic code: smtp;550 cuda_nsu No such recipient
48
+ Remote system: dns;spamfilter.bju.edu (TCP|1.1.1.1|62801|158.158.239.11|25) (spamfilter.bju.edu ESMTP [f4eed02af219fafc37154b1c2a9ef638])
49
+
50
+
51
+ --Boundary_(ID_i9HI+uq/Ow7SRFDKTB0YAg)
52
+ Content-type: message/delivery-status
53
+
54
+ Reporting-MTA: dns;vms169133.mailsrvcs.net (tcp-daemon)
55
+
56
+ Original-recipient: rfc822;fred@somewhere.com
57
+ Final-recipient: rfc822;fred@somewhere.com
58
+ Action: failed
59
+ Status: 5.0.0 (Remote SMTP server has rejected address)
60
+ Remote-MTA: dns;spamfilter.bju.edu (TCP|1.1.1.1|62801|158.158.239.11|25)
61
+ (spamfilter.bju.edu ESMTP [f4eed02af219fafc37154b1c2a9ef638])
62
+ Diagnostic-code: smtp;550 cuda_nsu No such recipient
63
+
64
+ --Boundary_(ID_i9HI+uq/Ow7SRFDKTB0YAg)
65
+ Content-type: message/rfc822
66
+
67
+ Return-path: <joe@example.com>
68
+ Received: from tcp-daemon.vms169133.mailsrvcs.net by vms169133.mailsrvcs.net
69
+ (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit))
70
+ id <0KKR00M9HQ3T8100@vms169133.mailsrvcs.net>; Fri,
71
+ 05 Jun 2009 08:43:05 -0500 (CDT)
72
+ Received: from mail.example.com ([1.1.1.1]) by vms169133.mailsrvcs.net
73
+ (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit))
74
+ with ESMTP id <0KKR00HD4Q3SBVF0@vms169133.mailsrvcs.net> for
75
+ egard789@students.bju.edu (ORCPT fred@somewhere.com); Fri,
76
+ 05 Jun 2009 08:43:05 -0500 (CDT)
77
+ Received: from mail.example.com (example.com [8.12.160.194]) by mail.example.com (Postfix)
78
+ with ESMTPA id 81EFD1780F1 for <fred@somewhere.com>; Fri,
79
+ 05 Jun 2009 06:42:53 -0700 (PDT)
80
+ Date: Fri, 05 Jun 2009 06:41:59 -0700
81
+ From: joe@example.com
82
+ Subject: I like turtles
83
+ X-Originating-IP: [1.1.1.1]
84
+ To: fred@somewhere.com
85
+ Message-id: <1234.1212@example.com>
86
+ MIME-version: 1.0
87
+ Content-type: text/html; charset=utf-8
88
+
89
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
90
+ <HTML>
91
+ <HEAD>
92
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
93
+ </HEAD>
94
+ <BODY bgcolor="#ffffff" topmargin="0" marginheight="0">
95
+ Hi
96
+ </BODY>
97
+ </HTML>
98
+
99
+ --Boundary_(ID_i9HI+uq/Ow7SRFDKTB0YAg)--
@@ -218,6 +218,45 @@ class TmailBouncerTest < Test::Unit::TestCase
218
218
 
219
219
  end
220
220
 
221
+ context "Verizon Bounce" do
222
+ setup do
223
+ @email = read_email('verizon.eml')
224
+ end
225
+
226
+ should "be a tmail object" do
227
+ assert @email.is_a?(TMail::Mail), "Whoops Im a #{@email.class}"
228
+ end
229
+
230
+ should "return StandardBouncer" do
231
+ assert @email.undeliverable_info.is_a?(TmailBouncer::StandardBouncer) , "Whoops Im a #{@email.class}"
232
+ end
233
+
234
+ should "detect bounced" do
235
+ assert_equal @email.undeliverable_info.status, "Failure"
236
+ end
237
+
238
+ should "detect original sender" do
239
+ assert_equal @email.undeliverable_info.original_sender, "joe@example.com"
240
+ end
241
+
242
+ should "detect original recipient" do
243
+ assert_equal @email.undeliverable_info.original_recipient, "fred@somewhere.com"
244
+ end
245
+
246
+ should "detect original subject" do
247
+ assert_equal @email.undeliverable_info.original_subject, "I like turtles"
248
+ end
249
+
250
+ should "detect original_message_id" do
251
+ assert_equal @email.undeliverable_info.original_message_id, "<1234.1212@example.com>"
252
+ end
253
+
254
+ should "return status of failure" do
255
+ assert_equal "Failure", @email.undeliverable_info.status
256
+ end
257
+ end
258
+
259
+
221
260
  protected
222
261
 
223
262
  def read_email(name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tangofoxtrot-tmail_bouncer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - tangofoxtrot
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-04 00:00:00 -07:00
12
+ date: 2009-06-05 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -37,6 +37,7 @@ files:
37
37
  - test/fixtures/legit_multipart.eml
38
38
  - test/fixtures/legit_with_quota.eml
39
39
  - test/fixtures/out_of_office.eml
40
+ - test/fixtures/verizon.eml
40
41
  - test/fixtures/yahoo.eml
41
42
  - test/fixtures/yahoo_legit.eml
42
43
  - test/test_helper.rb