1package Sisimai::Rhost::TencentQQ;
2use feature ':5.10';
3use strict;
4use warnings;
5
6sub 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    my $class = shift;
12    my $argvs = shift // return undef;
13
14    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    my $statusmesg = lc $argvs->diagnosticcode;
34    my $reasontext = '';
35
36    for my $e ( keys %$messagesof ) {
37        # Try to match the error message with message patterns defined in $MessagesOf
38        next unless index($statusmesg, $e) > -1;
39        $reasontext = $messagesof->{ $e };
40        last;
41    }
42    return $reasontext;
43}
44
451;
46__END__
47
48=encoding utf-8
49
50=head1 NAME
51
52Sisimai::Rhost::TencentQQ - Detect the bounce reason returned from Tencent QQ.
53
54=head1 SYNOPSIS
55
56    use Sisimai::Rhost;
57
58=head1 DESCRIPTION
59
60Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
61object as an argument of get() method when the value of C<rhost> of the object
62is "*.qq.com".  This class is called only Sisimai::Data class.
63
64=head1 CLASS METHODS
65
66=head2 C<B<get(I<Sisimai::Data Object>)>>
67
68C<get()> detects the bounce reason.
69
70=head1 AUTHOR
71
72azumakuniyuki
73
74=head1 COPYRIGHT
75
76Copyright (C) 2019,2020 azumakuniyuki, All rights reserved.
77
78=head1 LICENSE
79
80This software is distributed under The BSD 2-Clause License.
81
82=cut
83
84
85