File Coverage

lib/Sisimai/Reason/SpamDetected.pm
Criterion Covered Total %
statement 24 24 100.0
branch 10 12 83.3
condition 5 6 83.3
subroutine 7 7 100.0
pod 2 4 50.0
total 48 53 90.5


line stmt bran cond sub pod time code
1             package Sisimai::Reason::SpamDetected;
2 36     36   1834 use feature ':5.10';
  36         58  
  36         2319  
3 36     36   227 use strict;
  36         66  
  36         699  
4 36     36   142 use warnings;
  36         69  
  36         56168  
5              
6 43     43 1 101 sub text { 'spamdetected' }
7 4     4 0 18 sub description { 'Email rejected by spam filter running on the remote host' }
8             sub match {
9             # Try to match that the given text and regular expressions
10             # @param [String] argv1 String to be matched with regular expressions
11             # @return [Integer] 0: Did not match
12             # 1: Matched
13             # @since v4.1.19
14 909     909 1 2533 my $class = shift;
15 909   50     1696 my $argv1 = shift // return undef;
16              
17 909         1076 state $regex = qr{(?>
18             ["]the[ ]mail[ ]server[ ]detected[ ]your[ ]message[ ]as[ ]spam[ ]and[ ]
19             has[ ]prevented[ ]delivery[.]["] # CPanel/Exim with SA rejections on
20             |(?:\d[.]\d[.]\d|\d{3})[ ]spam\z
21             |554[ ]5[.]7[.]0[ ]reject,[ ]id=\d+
22             |appears[ ]to[ ]be[ ]unsolicited
23             |blacklisted[ ]url[ ]in[ ]message
24             |block[ ]for[ ]spam
25             |blocked[ ]by[ ](?:
26             policy:[ ]no[ ]spam[ ]please
27             |spamassassin # rejected by SpamAssassin
28             )
29             |blocked[ ]for[ ]abuse[.][ ]see[ ]http://att[.]net/blocks # AT&T
30             |bulk[ ]email
31             |considered[ ]unsolicited[ ]bulk[ ]e-mail[ ][(]spam[)][ ]by[ ]our[ ]mail[ ]filters
32             |content[ ]filter[ ]rejection
33             |cyberoam[ ]anti[ ]spam[ ]engine[ ]has[ ]identified[ ]this[ ]email[ ]as[ ]a[ ]bulk[ ]email
34             |denied[ ]due[ ]to[ ]spam[ ]list
35             |greylisted.?.[ ]please[ ]try[ ]again[ ]in
36             |high[ ]probability[ ]of[ ]spam
37             |https?://(?:www[.]spamhaus[.]org|dsbl[.]org|mail[.]163[.]com/help/help_spam_16[.]htm)
38             |listed[ ]in[ ]work[.]drbl[.]imedia[.]ru
39             |mail[ ](?:
40             appears[ ]to[ ]be[ ]unsolicited # rejected due to spam
41             |content[ ]denied # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726
42             |rejete[.][ ]mail[ ]rejected[.][ ][0-9a-z_]+506
43             )
44             |may[ ]consider[ ]spam
45             |message[ ](?:
46             considered[ ]as[ ]spam[ ]or[ ]virus
47             |content[ ]rejected
48             |filtered
49             |filtered[.][ ](?:
50             please[ ]see[ ]the[ ]faqs[ ]section[ ]on[ ]spam
51             |refer[ ]to[ ]the[ ]troubleshooting[ ]page[ ]at[ ]
52             )
53             |looks[ ]like[ ]spam
54             |refused[ ]by[ ](?:
55             mailmarshal[ ]spamprofiler
56             |trustwave[ ]seg[ ]spamprofiler
57             )
58             |rejected[ ](?:
59             as[ ]spam
60             |because[ ]of[ ]unacceptable[ ]content
61             |due[ ]to[ ]suspected[ ]spam[ ]content
62             |for[ ]policy[ ]reasons
63             )
64             )
65             |our[ ](?:
66             email[ ]server[ ]thinks[ ]this[ ]email[ ]is[ ]spam
67             |filters[ ]rate[ ]at[ ]and[ ]above[ ]\d+[ ]percent[ ]probability[ ]of[ ]being[ ]spam
68             |system[ ]has[ ]detected[ ]that[ ]this[ ]message[ ]is
69             )
70             |probable[ ]spam
71             |reject[ ]bulk[.]advertising
72             |rejected(?:
73             :[ ]spamassassin[ ]score[ ]
74             |[ ]by[ ][^ ]+[ ][(]spam[)]
75             |[ ]due[ ]to[ ]spam[ ](?:url[ ]in[ ])?(?:classification|content)
76             )
77             |rejecting[ ](?:banned|mail)[ ]content
78             |related[ ]to[ ]content[ ]with[ ]spam[-]like[ ]characteristics
79             |rule[ ]imposed[ ]as[ ][^ ]+[ ]is[ ]blacklisted[ ]on
80             |sender[ ]domain[ ]listed[ ]at[ ][^ ]+
81             |sending[ ]address[ ]not[ ]accepted[ ]due[ ]to[ ]spam[ ]filter
82             |spam[ ](?:
83             [^ ]+[ ]exceeded
84             |blocked
85             |check
86             |content[ ]matched
87             |detected
88             |email
89             |email[ ]not[ ]accepted
90             |message[ ]rejected[.] # mail.ru
91             |not[ ]accepted
92             |refused
93             |rejection
94             |reporting[ ]address # SendGrid|a message to an address has previously been marked as Spam by the recipient.
95             |score[ ]
96             )
97             |spambouncer[ ]identified[ ]spam # SpamBouncer identified SPAM
98             |spamming[ ]not[ ]allowed
99             |too[ ]much[ ]spam[.] # Earthlink
100             |the[ ]message[ ](?:
101             has[ ]been[ ]rejected[ ]by[ ]spam[ ]filtering[ ]engine
102             |was[ ]rejected[ ]due[ ]to[ ]classification[ ]as[ ]bulk[ ]mail
103             )
104             |the[ ]content[ ]of[ ]this[ ]message[ ]looked[ ]like[ ]spam # SendGrid
105             |this[ ](?:e-mail|mail)[ ](?:
106             cannot[ ]be[ ]forwarded[ ]because[ ]it[ ]was[ ]detected[ ]as[ ]spam
107             |is[ ]classified[ ]as[ ]spam[ ]and[ ]is[ ]rejected
108             )
109             |this[ ]message[ ](?:
110             appears[ ]to[ ]be[ ]spam
111             |has[ ]been[ ](?:
112             identified[ ]as[ ]spam
113             |scored[ ]as[ ]spam[ ]with[ ]a[ ]probability
114             )
115             |scored[ ][^ ]+[ ]spam[ ]points
116             |was[ ]classified[ ]as[ ]spam
117             |was[ ]rejected[ ]by[ ]recurrent[ ]pattern[ ]detection[ ]system
118             )
119             |transaction[ ]failed[ ]spam[ ]message[ ]not[ ]queued # SendGrid
120             |we[ ]dont[ ]accept[ ]spam
121             |you're[ ]using[ ]a[ ]mass[ ]mailer
122             |your[ ](?:
123             email[ ](?:
124             appears[ ]similar[ ]to[ ]spam[ ]we[ ]have[ ]received[ ]before
125             |breaches[ ]local[ ]uribl[ ]policy
126             |had[ ]spam[-]like[ ]
127             |is[ ](?:considered|probably)[ ]spam
128             |was[ ]detected[ ]as[ ]spam
129             )
130             |message[ ](?:
131             as[ ]spam[ ]and[ ]has[ ]prevented[ ]delivery
132             |has[ ]been[ ](?:
133             temporarily[ ]blocked[ ]by[ ]our[ ]filter
134             |rejected[ ]because[ ]it[ ]appears[ ]to[ ]be[ ]spam
135             )
136             |has[ ]triggered[ ]a[ ]spam[ ]block
137             |may[ ]contain[ ]the[ ]spam[ ]contents
138             |failed[ ]several[ ]antispam[ ]checks
139             )
140             )
141             )
142             }x;
143 909 100       28853 return 1 if $argv1 =~ $regex;
144 862         2069 return 0;
145             }
146              
147             sub true {
148             # Rejected due to spam content in the message
149             # @param [Sisimai::Data] argvs Object to be detected the reason
150             # @return [Integer] 1: rejected due to spam
151             # 0: is not rejected due to spam
152             # @since v4.1.19
153             # @see http://www.ietf.org/rfc/rfc2822.txt
154 748     748 0 1239 my $class = shift;
155 748   100     1647 my $argvs = shift // return undef;
156              
157 747 100       1793 return undef unless $argvs->deliverystatus;
158 575 50       2781 return 1 if $argvs->reason eq 'spamdetected';
159 575 50 100     2608 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'spamdetected';
160              
161             # The value of "reason" isn't "spamdetected" when the value of "smtpcommand" is an SMTP command
162             # to be sent before the SMTP DATA command because all the MTAs read the headers and the entire
163             # message body after the DATA command.
164 575 100       2003 return 0 if $argvs->{'smtpcommand'} =~ /\A(?:CONN|EHLO|HELO|MAIL|RCPT)\z/;
165 414 100       827 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
166 378         1283 return 0;
167             }
168              
169             1;
170             __END__