File Coverage

lib/Sisimai/Reason/UserUnknown.pm
Criterion Covered Total %
statement 35 35 100.0
branch 16 16 100.0
condition 5 6 83.3
subroutine 7 7 100.0
pod 2 4 50.0
total 65 68 95.5


line stmt bran cond sub pod time code
1             package Sisimai::Reason::UserUnknown;
2 59     59   1073 use feature ':5.10';
  59         103  
  59         4917  
3 59     59   282 use strict;
  59         91  
  59         980  
4 59     59   1082 use warnings;
  59         83  
  59         84695  
5              
6 731     731 1 2061 sub text { 'userunknown' }
7 4     4 0 13 sub description { "Email rejected due to a local part of a recipient's email address does not exist" }
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.0.0
14 1190     1190 1 1635 my $class = shift;
15 1190   50     2578 my $argv1 = shift // return undef;
16              
17 1190         1644 state $regex = qr{(?>
18             [#]5[.]1[.]1[ ]bad[ ]address
19             |[<][^ ]+[>][ ]not[ ]found
20             |[<][^ ]+[@][^ ]+[>][.][.][.][ ]blocked[ ]by[ ]
21             |550[ ]address[ ]invalid
22             |5[.]1[.]0[ ]address[ ]rejected[.]
23             |account[ ][^ ]+[ ]does[ ]not[ ]exist[ ]at[ ]the[ ]organization
24             |adresse[ ]d[ ]au[ ]moins[ ]un[ ]destinataire[ ]invalide[.][ ]invalid[ ]recipient[.][0-9a-z_]+41[68]
25             |address[ ](?:does[ ]not[ ]exist|not[ ]present[ ]in[ ]directory|unknown)
26             |archived[ ]recipient
27             |bad[-_ \t]recipient
28             |can[']t[ ]accept[ ]user
29             |does[ ]not[ ]exist[.]
30             |destination[ ](?:
31             addresses[ ]were[ ]unknown
32             |server[ ]rejected[ ]recipients
33             )
34             |email[ ]address[ ](?:does[ ]not[ ]exist|could[ ]not[ ]be[ ]found)
35             |invalid[ ](?:
36             address
37             |mailbox:?
38             |mailbox[ ]path|recipient
39             )
40             |is[ ]not[ ](?:
41             a[ ]known[ ]user
42             |a[ ]valid[ ]mailbox
43             |an[ ]active[ ]address[ ]at[ ]this[ ]host
44             )
45             |mailbox[ ](?:
46             [^ ]+[ ]does[ ]not[ ]exist
47             |[^ ]+[@][^ ]+[ ]unavailable
48             |does[ ]not[ ]exist
49             |invalid
50             |is[ ](?:inactive|unavailable)
51             |not[ ](?:present|found)
52             |unavailable
53             )
54             |nessun[ ]utente[ ]simile[ ]in[ ]questo[ ]indirizzo
55             |no[ ](?:
56             [ ][^ ]+[ ]in[ ]name[ ]directory
57             |account[ ]by[ ]that[ ]name[ ]here
58             |existe[ ](?:dicha[ ]persona|ese[ ]usuario[ ])
59             |mail[ ]box[ ]available[ ]for[ ]this[ ]user
60             |mailbox[ ](?:
61             by[ ]that[ ]name[ ]is[ ]currently[ ]available
62             |found
63             )
64             |matches[ ]to[ ]nameserver[ ]query
65             |such[ ](?:
66             address[ ]here
67             |mailbox
68             |person[ ]at[ ]this[ ]address
69             |recipient
70             |user(?:[ ]here)?
71             )
72             |thank[ ]you[ ]rejected:[ ]account[ ]unavailable:
73             |valid[ ]recipients,[ ]bye
74             )
75             |non[- ]?existent[ ]user
76             |not[ ](?:
77             a[ ]valid[ ](?:recipient|user[ ]here)
78             |a[ ]local[ ]address
79             |email[ ]addresses
80             )
81             |rcpt[ ][<][^ ]+[>][ ]does[ ]not[ ]exist
82             |recipient[ ]address[ ]rejected[.][ ][(]in[ ]reply[ ]to[ ]rcpt[ ]to[ ]command[)]
83             |recipient[ ](?:
84             [^ ]+[ ]was[ ]not[ ]found[ ]in
85             |address[ ]rejected:[ ](?:
86             access[ ]denied
87             |invalid[ ]user
88             |user[ ][^ ]+[ ]does[ ]not[ ]exist
89             |user[ ]unknown[ ]in[ ][^ ]+[ ]table
90             |unknown[ ]user
91             )
92             |does[ ]not[ ]exist(?:[ ]on[ ]this[ ]system)?
93             |is[ ]not[ ]local
94             |not[ ](?:exist|found|ok)
95             |unknown
96             )
97             |requested[ ]action[ ]not[ ]taken:[ ]mailbox[ ]unavailable
98             |resolver[.]adr[.]recipient notfound
99             |said:[ ]550[-[ ]]5[.]1[.]1[ ][^ ]+[ ]user[ ]unknown[ ]
100             |sorry,[ ](?:
101             user[ ]unknown
102             |badrcptto
103             |no[ ]mailbox[ ]here[ ]by[ ]that[ ]name
104             )
105             |the[ ](?:
106             email[ ]account[ ]that[ ]you[ ]tried[ ]to[ ]reach[ ]does[ ]not[ ]exist
107             |following[ ]recipients[ ]was[ ]undeliverable
108             |user[']s[ ]email[ ]name[ ]is[ ]not[ ]found
109             )
110             |there[ ]is[ ]no[ ]one[ ]at[ ]this[ ]address
111             |this[ ](?:
112             address[ ]no[ ]longer[ ]accepts[ ]mail
113             |email[ ]address[ ]is[ ]wrong[ ]or[ ]no[ ]longer[ ]valid
114             |spectator[ ]does[ ]not[ ]exist
115             |user[ ]doesn[']?t[ ]have[ ]a[ ][^ ]+[ ]account
116             )
117             |unknown[ ](?:
118             e[-]?mail[ ]address
119             |local[- ]part
120             |mailbox
121             |recipient
122             |user
123             )
124             |user[ ](?:
125             [^ ]+[ ]was[ ]not[ ]found
126             |[^ ]+[ ]does[ ]not[ ]exist
127             |does[ ]not[ ]exist
128             |missing[ ]home[ ]directory
129             |not[ ](?:active|exist|found|known)
130             |unknown
131             )
132             |utilisateur[ ]inconnu[ ]!
133             |vdeliver:[ ]invalid[ ]or[ ]unknown[ ]virtual[ ]user
134             |your[ ]envelope[ ]recipient[ ]is[ ]in[ ]my[ ]badrcptto[ ]list
135             )
136             }x;
137 1190 100       20767 return 1 if $argv1 =~ $regex;
138 824         2171 return 0;
139             }
140              
141             sub true {
142             # Whether the address is "userunknown" or not
143             # @param [Sisimai::Data] argvs Object to be detected the reason
144             # @return [Integer] 1: is unknown user
145             # 0: is not unknown user.
146             # @since v4.0.0
147             # @see http://www.ietf.org/rfc/rfc2822.txt
148 1792     1792 0 2636 my $class = shift;
149 1792   100     3595 my $argvs = shift // return undef;
150 1791 100       4107 return 1 if $argvs->reason eq 'userunknown';
151              
152 1594   100     8880 my $tempreason = Sisimai::SMTP::Status->name($argvs->deliverystatus) || '';
153 1594 100       4587 return 0 if $tempreason eq 'suspend';
154              
155 1589         3242 my $diagnostic = lc $argvs->diagnosticcode;
156 1589 100       8589 if( $tempreason eq 'userunknown' ) {
    100          
157             # *.1.1 = 'Bad destination mailbox address'
158             # Status: 5.1.1
159             # Diagnostic-Code: SMTP; 550 5.1.1 <***@example.jp>:
160             # Recipient address rejected: User unknown in local recipient table
161 378         638 state $prematches = [qw|NoRelaying Blocked MailboxFull HasMoved Rejected|];
162 378         706 state $ModulePath = {
163             'Sisimai::Reason::NoRelaying' => 'Sisimai/Reason/NoRelaying.pm',
164             'Sisimai::Reason::Blocked' => 'Sisimai/Reason/Blocked.pm',
165             'Sisimai::Reason::MailboxFull' => 'Sisimai/Reason/MailboxFull.pm',
166             'Sisimai::Reason::HasMoved' => 'Sisimai/Reason/HasMoved.pm',
167             'Sisimai::Reason::Rejected' => 'Sisimai/Reason/Rejected.pm',
168             };
169 378         582 my $matchother = 0;
170              
171 378         737 for my $e ( @$prematches ) {
172             # Check the value of "Diagnostic-Code" with other error patterns.
173 1875         2580 my $p = 'Sisimai::Reason::'.$e;
174 1875         25344 require $ModulePath->{ $p };
175              
176 1875 100       5313 next unless $p->match($diagnostic);
177             # Match with reason defined in Sisimai::Reason::* except UserUnknown.
178 15         28 $matchother = 1;
179 15         24 last;
180             }
181 378 100       1431 return 1 unless $matchother; # Did not match with other message patterns
182              
183             } elsif( $argvs->smtpcommand eq 'RCPT' ) {
184             # When the SMTP command is not "RCPT", the session rejected by other
185             # reason, maybe.
186 138 100       860 return 1 if __PACKAGE__->match($diagnostic);
187             }
188 1123         5620 return 0;
189             }
190              
191             1;
192             __END__