File Coverage

lib/Sisimai/Rhost/Tencent.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::Tencent;
2 6     6   1957 use v5.26;
  6         25  
3 6     6   37 use strict;
  6         11  
  6         161  
4 6     6   24 use warnings;
  6         11  
  6         2565  
5              
6             sub find {
7             # Detect bounce reason from Tencent
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] The bounce reason at Tencent
10             # @see https://service.mail.qq.com/detail/122
11             # @since v4.25.0
12 28     28 0 728 my $class = shift;
13 28 100 100     104 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  27         119  
14              
15 26         115 state $messagesof = {
16             'authfailure' => [
17             'spf check failed', # https://service.mail.qq.com/detail/122/72
18             'dmarc check failed',
19             ],
20             'blocked' => [
21             'suspected bounce attacks', # https://service.mail.qq.com/detail/122/57
22             'suspected spam ip', # https://service.mail.qq.com/detail/122/66
23             'connection denied', # https://service.mail.qq.com/detail/122/170
24             ],
25             'emailtoolarge' => [
26             'message too large', # https://service.mail.qq.com/detail/122/168
27             ],
28             'ratelimited' => [
29             'mailbox unavailable or access denined', # https://service.mail.qq.com/detail/122/166
30             'ip frequency limited', # https://service.mail.qq.com/detail/122/172
31             'domain frequency limited', # https://service.mail.qq.com/detail/122/173
32             'sender frequency limited', # https://service.mail.qq.com/detail/122/174
33             'connection frequency limited', # https://service.mail.qq.com/detail/122/175
34             "frequency of receiving messages is limited", # https://service.mail.qq.com/detail/122/1011
35             ],
36             'rejected' => [
37             'suspected spam', # https://service.mail.qq.com/detail/122/71
38             'mail is rejected by recipients', # https://service.mail.qq.com/detail/122/92
39             ],
40             'spamdetected' => [
41             'spam is embedded in the email', # https://service.mail.qq.com/detail/122/59
42             'mail content denied', # https://service.mail.qq.com/detail/122/171
43             ],
44             'suspend' => [
45             'is a deactivated mailbox', # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000742
46             ],
47             'syntaxerror' => [
48             'bad address syntax', # https://service.mail.qq.com/detail/122/167
49             ],
50             'userunknown' => [
51             'mailbox not found', # https://service.mail.qq.com/detail/122/169
52             ],
53             };
54 26         86 my $issuedcode = lc $argvs->{'diagnosticcode'};
55 26         41 my $reasontext = '';
56              
57 26         127 for my $e ( keys %$messagesof ) {
58             # Try to find the error message matches with the given error message string
59 209 100       1297 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  444         881  
60 19         39 $reasontext = $e;
61 19         33 last;
62             }
63 26         138 return $reasontext;
64             }
65              
66             1;
67             __END__