File Coverage

lib/Sisimai/Rhost/TencentQQ.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::TencentQQ;
2 5     5   1543 use feature ':5.10';
  5         12  
  5         428  
3 5     5   28 use strict;
  5         10  
  5         102  
4 5     5   24 use warnings;
  5         9  
  5         1001  
5              
6             sub get {
7             # Detect bounce reason from Tencent QQ
8             # @param [Sisimai::Data] argvs Parsed email object
9             # @return [String] The bounce reason at Tencent QQ
10             # @since v4.25.0
11 20     20 0 941 my $class = shift;
12 20   100     69 my $argvs = shift // return undef;
13              
14 19         80 state $messagesof = {
15             # https://service.mail.qq.com/cgi-bin/help?id=20022
16             'dmarc check failed' => 'blocked',
17             'spf check failed' => 'blocked',
18             'suspected spam ip' => 'blocked',
19             'mail is rejected by recipients' => 'filtered',
20             'message too large' => 'mesgtoobig',
21             'mail content denied' => 'spamdetected',
22             'spam is embedded in the email' => 'spamdetected',
23             'suspected spam' => 'spamdetected',
24             'bad address syntax' => 'syntaxerror',
25             'connection denied' => 'toomanyconn',
26             'connection frequency limited' => 'toomanyconn',
27             'domain frequency limited' => 'toomanyconn',
28             'ip frequency limited' => 'toomanyconn',
29             'sender frequency limited' => 'toomanyconn',
30             'mailbox unavailable or access denied' => 'toomanyconn',
31             'mailbox not found' => 'userunknown',
32             };
33 19         62 my $statusmesg = lc $argvs->diagnosticcode;
34 19         126 my $reasontext = '';
35              
36 19         118 for my $e ( keys %$messagesof ) {
37             # Try to match the error message with message patterns defined in $MessagesOf
38 185 100       466 next unless index($statusmesg, $e) > -1;
39 19         42 $reasontext = $messagesof->{ $e };
40 19         36 last;
41             }
42 19         68 return $reasontext;
43             }
44              
45             1;
46             __END__