1package Sisimai::Rhost::FrancePTT;
2use feature ':5.10';
3use strict;
4use warnings;
5
6sub get {
7    # Detect bounce reason from Orange and La Poste
8    # @param    [Sisimai::Data] argvs   Parsed email object
9    # @return   [String]                The bounce reason for Orange, La Poste
10    my $class = shift;
11    my $argvs = shift // return undef;
12    return $argvs->reason if $argvs->reason;
13
14    state $errorcodes = {
15        # 550 5.7.1 Service unavailable; client [X.X.X.X] blocked using Spamhaus
16        # Les emails envoyes vers la messagerie Laposte.net ont ete bloques par nos services.
17        # Afin de regulariser votre situation, nous vous invitons a cliquer sur le lien ci-dessous et a suivre la procedure.
18        # The emails sent to the mail host Laposte.net were blocked by our services.
19        # To regularize your situation please click on the link below and follow the procedure
20        # https://www.spamhaus.org/lookup/ LPNAAA_101 (in reply to RCPT TO command))
21        '101' => 'blocked',
22
23        # 550 mwinf5c04 ME Adresse IP source bloquee pour incident de spam.
24        # Client host blocked for spamming issues. OFR006_102 Ref
25        #
26        # refused to talk to me: 550 5.5.0 Les emails envoyes vers la messagerie Laposte.net ont ete bloques par nos services.
27        # Afin de regulariser votre situation, nous vous invitons a cliquer sur le lien ci-dessous et a suivre la procedure.
28        # The emails sent to the mail host Laposte.net were blocked by our services.
29        # To regularize your situation please click on the link below and follow the procedure
30        # https://senderscore.org/blacklistlookup/  LPN007_102
31        '102' => 'blocked',
32
33        # refused to talk to me: 550 mwinf5c10 ME Service refuse. Veuillez essayer plus tard.
34        # Service refused, please try later. OFR006_103 X.X.X.X [103]
35        '103' => 'blocked',
36
37        # refused to talk to me: 421 mwinf5c79 ME Trop de connexions, veuillez verifier votre configuration.
38        # Too many connections, slow down. OFR005_104 [104]
39        # Too many connections, slow down. LPN105_104
40        '104' => 'toomanyconn',
41
42        # Veuillez essayer plus tard.
43        '105' => undef,
44
45        # refused to talk to me: 421 4.2.1 Service refuse. Veuillez essayer plus tard.
46        # Service refused, please try later. LPN006_107)
47        '107' => undef,
48
49        # refused to talk to me: 550 5.5.0 Service refuse. Veuillez essayer plus tard.
50        # service refused, please try later. LPN001_108
51        '108' => undef,
52
53        # Veuillez essayer plus tard. LPN003_109
54        '109' => undef,
55
56        # Veuillez essayer plus tard. OFR004_201
57        '201' => undef,
58
59        # 550 5.7.0 Code d'authentification invalide OFR_305
60        '305' => 'securityerror',
61
62        # 550 5.5.0 SPF: *** is not allowed to send mail. LPN004_401
63        '401' => 'blocked',
64
65        # 550 5.5.0 Authentification requise. Authentication Required. LPN105_402
66        '402' => 'securityerror',
67
68        # 5.0.1 Emetteur invalide. Invalid Sender.
69        '403' => 'rejected',
70
71        # 5.0.1 Emetteur invalide. Invalid Sender. LPN105_405
72        # 501 5.1.0 Emetteur invalide. Invalid Sender. OFR004_405 [405] (in reply to MAIL FROM command))
73        '405' => 'rejected',
74
75        # Emetteur invalide. Invalid Sender. OFR_415
76        '415' => 'rejected',
77
78        # 550 5.1.1 Adresse d au moins un destinataire invalide.
79        # Invalid recipient. LPN416 (in reply to RCPT TO command)
80        # Invalid recipient. OFR_416 [416] (in reply to RCPT TO command)
81        '416' => 'userunknown',
82
83        # 552 5.1.1 Boite du destinataire pleine.
84        # Recipient overquota. OFR_417 [417] (in reply to RCPT TO command))
85        '417' => 'mailboxfull',
86
87        # Adresse d au moins un destinataire invalide
88        '418' => 'userunknown',
89
90        # 550 5.5.0 Boite du destinataire archivee.
91        # Archived recipient. LPN007_420 (in reply to RCPT TO command)
92        '420' => 'suspend',
93
94        # 5.5.3 Mail from not owned by user. LPN105_421.
95        '421' => 'rejected',
96
97        # Service refused, please try later. LPN105_423
98        '423' => undef,
99
100        # Veuillez essayer plus tard. LPN105_424
101        '424' => undef,
102
103        # 550 5.5.0 Le compte du destinataire est bloque. The recipient account isblocked. LPN007_426 (in reply to RCPT TO command)
104        '426' => 'suspend',
105
106        # 421 4.2.0 Service refuse. Veuillez essayer plus tard.
107        # Service refused, please try later. OFR005_505 [505] (in reply to end of DATA command)
108        #
109        # 421 4.2.1 Service refuse. Veuillez essayer plus tard.
110        # Service refused, please try later. LPN007_505 (in reply to end of DATA command)
111        '505' => 'systemerror',
112
113        # Mail rejete. Mail rejected. OFR_506 [506]
114        '506' => 'spamdetected',
115
116        # 550 5.5.0 Service refuse. Veuillez essayer plus tard.
117        # service refused, please try later. LPN005_510 (in reply to end of DATA command)
118        '510' => 'blocked',
119
120        # Mail rejete. Mail rejected. OUK_513
121        '513' => undef,
122
123        # Taille limite du message atteinte
124        '514' => 'mesgtoobig',
125
126        # 571 5.7.1 Message refused, DMARC verification Failed.
127        # Message refuse, verification DMARC en echec LPN007_517
128        '517' => 'policyviolation',
129
130        # 421 mwinf5c77 ME Service refuse. Veuillez essayer plus tard.
131        # Service refused, please try later. OFR_999 [999]
132        '999' => 'blocked',
133    };
134
135    my $statusmesg = $argvs->diagnosticcode;
136    my $reasontext = '';
137
138    if( $statusmesg =~ /\b(LPN|LPNAAA|OFR|OUK)(_[0-9]{3}|[0-9]{3}[-_][0-9]{3})\b/i ) {
139        # OUK_513, LPN105-104, OFR102-104, ofr_506
140        my $v = sprintf("%03d", substr($1.$2, -3, 3));
141        $reasontext = $errorcodes->{ $v } || 'undefined';
142    }
143    return $reasontext;
144}
145
1461;
147__END__
148
149=encoding utf-8
150
151=head1 NAME
152
153Sisimai::Rhost::FrancePTT - Detect the bounce reason returned from Orange and
154La Poste.
155
156=head1 SYNOPSIS
157
158    use Sisimai::Rhost;
159
160=head1 DESCRIPTION
161
162Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
163object as an argument of get() method when the value of C<rhost> of the object
164end with "laposte.net" or "orange.fr".
165This class is called only Sisimai::Data class.
166
167=head1 CLASS METHODS
168
169=head2 C<B<get(I<Sisimai::Data Object>)>>
170
171C<get()> detects the bounce reason.
172
173=head1 AUTHOR
174
175azumakuniyuki
176
177=head1 COPYRIGHT
178
179Copyright (C) 2017-2020 azumakuniyuki, All rights reserved.
180
181=head1 LICENSE
182
183This software is distributed under The BSD 2-Clause License.
184
185=cut
186
187