File Coverage

lib/Sisimai/Rhost/FrancePTT.pm
Criterion Covered Total %
statement 26 28 92.8
branch 7 8 87.5
condition 5 5 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 42 46 91.3


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::FrancePTT;
2 8     8   2530 use v5.26;
  8         31  
3 8     8   49 use strict;
  8         12  
  8         228  
4 8     8   52 use warnings;
  8         15  
  8         5134  
5              
6             sub find {
7             # Detect bounce reason from Orange and La Poste
8             # @param [Sisimai::Fact] argvs Decdoed email object
9             # @return [String] The bounce reason for Orange, La Poste
10             # @see
11             # - Orange Postmaster Page: https://postmaster.orange.fr/index.html
12             # - https://www.postmastery.com/orange-postmaster-smtp-error-codes-ofr/
13             # - https://smtpfieldmanual.com/provider/orange
14             # @since v4.22.3
15 91     91 0 1281 my $class = shift;
16 91 100 100     290 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  90         380  
17              
18 84         351 state $errorcodes = {
19             # - Your sending IP is listed on Abusix RBL
20             # Please visit: https://lookup.abusix.com/search?q=$IP
21             "100" => 'blocked',
22              
23             # - Your sending IP is listed by SpamHaus RBL
24             # Please visit: https://check.spamhaus.org/listed/?searchterm=$IP
25             # - 550 5.7.1 Service unavailable; client [192.0.2.1] blocked using Spamhaus
26             # 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
28             # et a suivre la procedure.
29             # - The emails sent to the mail host Laposte.net were blocked by our services. To regularize
30             # your situation please click on the link below and follow the procedure
31             # https://www.spamhaus.org/lookup/ LPNAAA_101 (in reply to RCPT TO command))
32             '101' => 'blocked',
33              
34             # - Your sending IP is listed by Cloudmark RBL
35             # Please visit: https://csi.cloudmark.com/reset-request/?ip=$IP#
36             # - 550 mwinf5c04 ME Adresse IP source bloquee pour incident de spam.
37             # - Client host blocked for spamming issues. OFR006_102 Ref http://csi.cloudmark.com ...
38             # - 550 5.5.0 Les emails envoyes vers la messagerie Laposte.net ont ete bloques par nos
39             # services. Afin de regulariser votre situation, nous vous invitons a cliquer sur le lien
40             # ci-dessous et a suivre la procedure.
41             # - The emails sent to the mail host Laposte.net were blocked by our services. To regularize
42             # your situation please click on the link below and follow the procedure
43             # https://senderscore.org/blacklistlookup/ LPN007_102
44             '102' => 'blocked',
45              
46             # - Your sending IP has been blacklisted by Orange
47             # Please contact Orange by using our contact form and select option
48             # "Un problème d'envoi d'emails vers les adresses Orange ou Wanadoo (deliverability issue)"
49             # - 550 mwinf5c10 ME Service refuse. Veuillez essayer plus tard.
50             # - Service refused, please try later. OFR006_103 192.0.2.1 [103]
51             '103' => 'blocked',
52              
53             # - 421 mwinf5c79 ME Trop de connexions, veuillez verifier votre configuration.
54             # - Too many connections, slow down. OFR005_104 [104]
55             # - Too many connections, slow down. LPN105_104
56             '104' => 'ratelimited',
57              
58             # - Your IP address is missing a DNS PTR record, it also called a rDNS (reverse DNS)
59             # Please set up a valid DNS PTR record for your IP address that point to your domain,
60             # It's important that the sending IP address must match the IP address of the hostname
61             # defined in the PTR record
62             # - Service refused, please try later. LPN006_107
63             "107" => 'requireptr',
64              
65             # - You are sending too many messages per SMTP connection
66             # Please reduce the number of messages per connection, recommended value is 100
67             # messages per connections
68             # - Veuillez essayer plus tard. LPN003_109
69             "109" => 'ratelimited',
70              
71             # - Invalid HELO/EHLO
72             # Please set up a valid HELO/EHLO, it must be fully qualified domain name (FQDN) and
73             # should resolve (DNS record needed). E.g.: "mail.yourdomain.com"
74             # - Veuillez essayer plus tard. OFR004_201
75             "201" => 'blocked',
76             "20X" => 'blocked',
77              
78             # - Sender's Domain name SPF Error
79             # Please verify your mail from domain name DNS/TXT configuration for your SPF
80             # configuration. Please visit https://mxtoolbox.com/supertool3?action=spf:$YOUR_DOMAIN
81             # to check your domain. (replace $YOUR_DOMAIN by your sender domain name)
82             # Please note:
83             # If you have changed your DNS record recently, please let DNS caches expire (TTL)
84             "39X" => 'authfailure',
85              
86             # - Sender's Domain DNS Error
87             # Please verify your mail from domain name DNS configuration. Your domain name must
88             # have valid A or MX records. You can check your DNS configuration on MxToolBox
89             # Please note:
90             # If you have changed your DNS record recently, please let DNS caches expire (TTL)
91             # - 5.0.1 Emetteur invalide. Invalid Sender. LPN105_405
92             # - 501 5.1.0 Emetteur invalide. Invalid Sender. OFR004_405 [405] (in reply to MAIL FROM command))
93             '405' => 'rejected',
94              
95             # - Your Sender has been rejected
96             # Please contact Orange by using our contact form and select option
97             # "Un problème d'envoi d'emails vers les adresses Orange ou Wanadoo (deliverability issue)"
98             "406" => 'rejected',
99              
100             # - User doesn't exist here
101             # Please remove this email address from your distribution list, it does not exist
102             # - 550 5.1.1 Adresse d au moins un destinataire invalide.
103             # - Invalid recipient. LPN416 (in reply to RCPT TO command)
104             # - Invalid recipient. OFR_416 [416] (in reply to RCPT TO command)
105             '416' => 'userunknown',
106              
107             # - 552 5.1.1 Boite du destinataire pleine.
108             # - Recipient overquota. OFR_417 [417] (in reply to RCPT TO command))
109             '417' => 'mailboxfull',
110              
111             # - 550 5.5.0 Boite du destinataire archivee.
112             # - Archived recipient. LPN007_420 (in reply to RCPT TO command)
113             '420' => 'suspend',
114              
115             # - Your sender domain name has been blacklisted
116             # Your sender domain name has been blacklisted by Abusix OR SpamHaus, Please visit:
117             # - https://lookup.abusix.com/search?q=$YOUR_DOMAIN
118             # - https://check.spamhaus.org/listed/?searchterm=$YOUR_DOMAIN
119             "425" => 'rejected',
120              
121             # - 550 5.5.0 Le compte du destinataire est bloque. The recipient account isblocked.
122             # LPN007_426 (in reply to RCPT TO command)
123             '426' => 'suspend',
124              
125             # - 421 4.2.0 Service refuse. Veuillez essayer plus tard. Service refused, please try later.
126             # OFR005_505 [505] (in reply to end of DATA command)
127             # - 421 4.2.1 Service refuse. Veuillez essayer plus tard. Service refused, please try later.
128             # LPN007_505 (in reply to end of DATA command)
129             '505' => 'systemerror',
130              
131             # - Your message has been blocked by Orange, suspected spam
132             # Please contact Orange by using our contact form and select option
133             # "Un problème d'envoi d'emails vers les adresses Orange ou Wanadoo (deliverability issue)"
134             # - Mail rejete. Mail rejected. OFR_506 [506]
135             '506' => 'spamdetected',
136              
137             # - 550 5.5.0 Service refuse. Veuillez essayer plus tard. service refused, please try later.
138             # LPN005_510 (in reply to end of DATA command)
139             '510' => 'blocked',
140              
141             # - DMARC authentication failed, message rejected as defined by your DMARC policy
142             # Please check your SPF/DKIM/DMARC configuration. Please visit MxToolBox DMARC to
143             # check your domain configuration
144             "515" => 'authfailure',
145              
146             # - 571 5.7.1 Message refused, DMARC verification Failed.
147             # - Message refuse, verification DMARC en echec LPN007_517
148             '517' => 'authfailure',
149              
150             # - The sending IP address is not authorized to send messages for your domain as defined
151             # in the sender's Domain name SPF configuration (DNS/TXT)
152             # Please verify your mail from domain name DNS/TXT configuration for your SPF configuration.
153             # Please visit https://mxtoolbox.com/supertool3?action=spf:$YOUR_DOMAIN to check your
154             # domain. (replace $YOUR_DOMAIN by your sender domain name)
155             "519" => 'authfailure',
156              
157             # - Due to bad behavior you have been rate limited, please try again later
158             # Due to inappropriate behavior, you have been rate limited. Please check what you
159             # are trying to send
160             # - 421 mwinf5c77 ME Service refuse. Veuillez essayer plus tard. Service refused, please try
161             # later. OFR_999 [999]
162             "99X" => 'ratelimited',
163              
164             # Other undocumented or old error codes
165             "105" => "", # Veuillez essayer plus tard.
166             "108" => "", # service refused, please try later. LPN001_108
167             "305" => "securityerror", # 550 5.7.0 Code d'authentification invalide OFR_305
168             "401" => "authfailure", # 550 5.5.0 SPF: *** is not allowed to send mail. LPN004_401
169             "402" => "securityerror", # 550 5.5.0 Authentification requise. Authentication Required. LPN105_402
170             "403" => "rejected", # 5.0.1 Emetteur invalide. Invalid Sender.
171             "415" => "rejected", # Emetteur invalide. Invalid Sender. OFR_415
172             "421" => "rejected", # 5.5.3 Mail from not owned by user. LPN105_421.
173             "423" => "", # Service refused, please try later. LPN105_423
174             "424" => "", # Veuillez essayer plus tard. LPN105_424
175             "513" => "", # Mail rejete. Mail rejected. OUK_513
176             "514" => "messagetoobig", # Taille limite du message atteinte
177             "630" => "policyviolation", # 554 5.7.1 Client host rejected LPN000_630
178             };
179 84         191 state $messagesof = {
180             'authfailure' => [
181             # - 421 smtp.orange.fr [192.0.2.1] Emetteur invalide, Veuillez verifier la configuration
182             # SPF/DNS de votre nom de domaine. Invalid Sender. SPF check failed, please verify the
183             # SPF/DNS configuration for your domain name.
184             'spf/dns de votre nom de domaine',
185             ],
186             };
187 84         190 my $issuedcode = $argvs->{'diagnosticcode'};
188 84         190 my $reasontext = '';
189              
190 84 100       1569 if( $issuedcode =~ /\b(LPN|LPNAAA|OFR|OUK)(_[0-9]{3}|[0-9]{3}[-_][0-9]{3})\b/i ) {
191             # OUK_513, LPN105-104, OFR102-104, ofr_506
192 82         774 my $v = sprintf("%03d", substr($1.$2, -3, 3));
193 82         249 my $x = $v; $x =~ s/.\z/X/;
  82         859  
194 82   100     420 $reasontext = $errorcodes->{ $v } || $errorcodes->{ $x };
195             }
196 84 100       448 return $reasontext if length $reasontext;
197              
198 8         26 $issuedcode = lc $issuedcode;
199 8         29 for my $e ( keys %$messagesof ) {
200             # Try to find the error message matches with the given error message string
201 8 50       21 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  8         71  
202 0         0 $reasontext = $e;
203 0         0 last;
204             }
205 8         37 return $reasontext;
206             }
207              
208             1;
209             __END__