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   2087 use feature ':5.10';
  36         74  
  36         2597  
3 36     36   206 use strict;
  36         72  
  36         770  
4 36     36   190 use warnings;
  36         69  
  36         63720  
5              
6 43     43 1 118 sub text { 'spamdetected' }
7 4     4 0 21 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 954     954 1 3286 my $class = shift;
15 954   50     2185 my $argv1 = shift // return undef;
16              
17 954         1330 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             |contains[ ]spam[ ]or[ ]virus
48             |content[ ]rejected
49             |detected[ ]as[ ]spam
50             |filtered
51             |filtered[.][ ](?:
52             please[ ]see[ ]the[ ]faqs[ ]section[ ]on[ ]spam
53             |refer[ ]to[ ]the[ ]troubleshooting[ ]page[ ]at[ ]
54             )
55             |is[ ]being[ ]rejected[ ]as[ ]it[ ]seems[ ]to[ ]be[ ]a[ ]spam
56             |looks[ ]like[ ]spam
57             |refused[ ]by[ ](?:
58             mailmarshal[ ]spamprofiler
59             |trustwave[ ]seg[ ]spamprofiler
60             )
61             |rejected[ ](?:
62             as[ ]spam
63             |because[ ]of[ ]unacceptable[ ]content
64             |due[ ]to[ ]suspected[ ]spam[ ]content
65             |for[ ]policy[ ]reasons
66             )
67             )
68             |our[ ](?:
69             email[ ]server[ ]thinks[ ]this[ ]email[ ]is[ ]spam
70             |filters[ ]rate[ ]at[ ]and[ ]above[ ]\d+[ ]percent[ ]probability[ ]of[ ]being[ ]spam
71             |system[ ]has[ ]detected[ ]that[ ]this[ ]message[ ]is
72             )
73             |probable[ ]spam
74             |reject[ ]bulk[.]advertising
75             |rejected(?:
76             :[ ]spamassassin[ ]score[ ]
77             |[ ]by[ ][^ ]+[ ][(]spam[)]
78             |[ ]due[ ]to[ ]spam[ ](?:url[ ]in[ ])?(?:classification|content)
79             )
80             |rejecting[ ](?:banned|mail)[ ]content
81             |related[ ]to[ ]content[ ]with[ ]spam[-]like[ ]characteristics
82             |rule[ ]imposed[ ]as[ ][^ ]+[ ]is[ ]blacklisted[ ]on
83             |sender[ ]domain[ ]listed[ ]at[ ][^ ]+
84             |sending[ ]address[ ]not[ ]accepted[ ]due[ ]to[ ]spam[ ]filter
85             |spam[ ](?:
86             [^ ]+[ ]exceeded
87             |blocked
88             |check
89             |content[ ]matched
90             |detected
91             |email
92             |email[ ]not[ ]accepted
93             |message[ ]rejected[.] # mail.ru
94             |not[ ]accepted
95             |refused
96             |rejection
97             |reporting[ ]address # SendGrid|a message to an address has previously been marked as Spam by the recipient.
98             |score[ ]
99             )
100             |spambouncer[ ]identified[ ]spam # SpamBouncer identified SPAM
101             |spamming[ ]not[ ]allowed
102             |too[ ]much[ ]spam[.] # Earthlink
103             |the[ ]email[ ]message[ ]was[ ]detected[ ]as[ ]spam
104             |the[ ]message[ ](?:
105             has[ ]been[ ]rejected[ ]by[ ]spam[ ]filtering[ ]engine
106             |was[ ]rejected[ ]due[ ]to[ ]classification[ ]as[ ]bulk[ ]mail
107             )
108             |the[ ]content[ ]of[ ]this[ ]message[ ]looked[ ]like[ ]spam # SendGrid
109             |this[ ](?:e-mail|mail)[ ](?:
110             cannot[ ]be[ ]forwarded[ ]because[ ]it[ ]was[ ]detected[ ]as[ ]spam
111             |is[ ]classified[ ]as[ ]spam[ ]and[ ]is[ ]rejected
112             )
113             |this[ ]message[ ](?:
114             appears[ ]to[ ]be[ ]spam
115             |has[ ]been[ ](?:
116             identified[ ]as[ ]spam
117             |scored[ ]as[ ]spam[ ]with[ ]a[ ]probability
118             )
119             |scored[ ][^ ]+[ ]spam[ ]points
120             |was[ ]classified[ ]as[ ]spam
121             |was[ ]rejected[ ]by[ ]recurrent[ ]pattern[ ]detection[ ]system
122             )
123             |transaction[ ]failed[ ]spam[ ]message[ ]not[ ]queued # SendGrid
124             |we[ ]dont[ ]accept[ ]spam
125             |you're[ ]using[ ]a[ ]mass[ ]mailer
126             |your[ ](?:
127             email[ ](?:
128             appears[ ]similar[ ]to[ ]spam[ ]we[ ]have[ ]received[ ]before
129             |breaches[ ]local[ ]uribl[ ]policy
130             |had[ ]spam[-]like[ ]
131             |is[ ](?:considered|probably)[ ]spam
132             |was[ ]detected[ ]as[ ]spam
133             )
134             |message[ ](?:
135             as[ ]spam[ ]and[ ]has[ ]prevented[ ]delivery
136             |has[ ]been[ ](?:
137             temporarily[ ]blocked[ ]by[ ]our[ ]filter
138             |rejected[ ]because[ ]it[ ]appears[ ]to[ ]be[ ]spam
139             )
140             |has[ ]triggered[ ]a[ ]spam[ ]block
141             |may[ ]contain[ ]the[ ]spam[ ]contents
142             |failed[ ]several[ ]antispam[ ]checks
143             )
144             )
145             )
146             }x;
147 954 100       33917 return 1 if $argv1 =~ $regex;
148 907         2604 return 0;
149             }
150              
151             sub true {
152             # Rejected due to spam content in the message
153             # @param [Sisimai::Data] argvs Object to be detected the reason
154             # @return [Integer] 1: rejected due to spam
155             # 0: is not rejected due to spam
156             # @since v4.1.19
157             # @see http://www.ietf.org/rfc/rfc2822.txt
158 728     728 0 1380 my $class = shift;
159 728   100     1785 my $argvs = shift // return undef;
160              
161 727 100       1854 return undef unless $argvs->deliverystatus;
162 555 50       3145 return 1 if $argvs->reason eq 'spamdetected';
163 555 50 100     3002 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'spamdetected';
164              
165             # The value of "reason" isn't "spamdetected" when the value of "smtpcommand" is an SMTP command
166             # to be sent before the SMTP DATA command because all the MTAs read the headers and the entire
167             # message body after the DATA command.
168 555 100       2557 return 0 if $argvs->{'smtpcommand'} =~ /\A(?:CONN|EHLO|HELO|MAIL|RCPT)\z/;
169 404 100       1081 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
170 368         1050 return 0;
171             }
172              
173             1;
174             __END__