File Coverage

lib/Sisimai/SMTP/Status.pm
Criterion Covered Total %
statement 37 39 94.8
branch 6 8 75.0
condition 13 15 86.6
subroutine 8 8 100.0
pod 3 3 100.0
total 67 73 91.7


line stmt bran cond sub pod time code
1             package Sisimai::SMTP::Status;
2 80     80   69578 use feature ':5.10';
  80         170  
  80         5930  
3 80     80   484 use strict;
  80         165  
  80         1476  
4 80     80   392 use warnings;
  80         143  
  80         31707  
5              
6             # http://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
7             #
8             # ------------------------------------------------------------------------------
9             # [Class Sub-Codes]
10             # 2.X.Y Success
11             # 4.X.Y Persistent Transient Failure
12             # 5.X.Y Permanent Failure
13             #
14             # ------------------------------------------------------------------------------
15             # [Subject Sub-Codes]
16             #
17             # X.0.X --- Other or Undefined Status
18             # There is no additional subject information available.
19             #
20             # X.1.X --- Addressing Status
21             # The address status reports on the originator or destination address.
22             # It may include address syntax or validity.
23             # These errors can generally be corrected by the sender and retried.
24             #
25             # X.2.X --- Mailbox Status
26             # Mailbox status indicates that something having to do with the mailbox
27             # has caused this DSN. Mailbox issues are assumed to be under the general
28             # control of the recipient.
29             #
30             # X.3.X --- Mail System Status
31             # Mail system status indicates that something having to do with the
32             # destination system has caused this DSN. System issues are assumed to
33             # be under the general control of the destination system administrator.
34             #
35             # X.4.X --- Network and Routing Status
36             # The networking or routing codes report status about the delivery
37             # system itself. These system components include any necessary
38             # infrastructure such as directory and routing services. Network issues
39             # are assumed to be under the control of the destination or intermediate
40             # system administrator.
41             #
42             # X.5.X --- Mail Delivery Protocol Status
43             # The mail delivery protocol status codes report failures involving
44             # the message delivery protocol. These failures include the full range
45             # of problems resulting from implementation errors or an unreliable
46             # connection.
47             #
48             # X.6.X --- Message Content or Media Status
49             # The message content or media status codes report failures involving
50             # the content of the message. These codes report failures due to
51             # translation, transcoding, or otherwise unsupported message media.
52             # Message content or media issues are under the control of both the
53             # sender and the receiver, both of which must support a common set of
54             # supported content-types.
55             #
56             # X.7.X --- Security or Policy Status
57             # The security or policy status codes report failures involving policies
58             # such as per-recipient or per-host filtering and cryptographic operations.
59             # Security and policy status issues are assumed to be under the control
60             # of either or both the sender and recipient.
61             # Both the sender and recipient must permit the exchange of messages
62             # and arrange the exchange of necessary keys and certificates for
63             # cryptographic operations.
64             #
65             # ------------------------------------------------------------------------------
66             # [Enumerated Status Codes]
67             #
68             # X.0.0 Any Other undefined Status:(RFC 3463)
69             # Other undefined status is the only undefined error code. It
70             # should be used for all errors for which only the class of the
71             # error is known.
72             #
73             # X.1.0 --- Other address status:(RFC 3463)
74             # Something about the address specified in the message caused
75             # this DSN.
76             #
77             # X.1.1 451 Bad destination mailbox address:(RFC 3463)
78             # 550 The mailbox specified in the address does not exist.
79             # For Internet mail names, this means the address portion to the
80             # the left of the "@" sign is invalid.
81             # This code is only useful for permanent failures.
82             #
83             # X.1.2 --- Bad destination system addres:
84             # The destination system specified in the address does not exist
85             # or is incapable of accepting mail. For Internet mail names,
86             # this means the address portion to the right of the "@" is
87             # invalid for mail.
88             # This code is only useful for permanent failures.
89             #
90             # X.1.3 501 Bad destination mailbox address syntax:
91             # The destination address was syntactically invalid. This can
92             # apply to any field in the address. This code is only useful
93             # for permanent failures.
94             #
95             # X.1.4 --- Destination mailbox address ambiguous:(RFC 3463)
96             # The mailbox address as specified matches one or more recipients
97             # on the destination system.
98             # This may result if a heuristic address mapping algorithm is
99             # used to map the specified address to a local mailbox name.
100             #
101             # X.1.5 250 Destination address valid:(RFC 3463)
102             # This mailbox address as specified was valid. This status code
103             # should be used for positive delivery reports.
104             #
105             # X.1.6 --- Destination mailbox has moved, No forwarding address:(RFC 3463)
106             # The mailbox address provided was at one time valid, but mail
107             # is no longer being accepted for that address.
108             # This code is only useful for permanent failures.
109             #
110             # X.1.7 --- Bad sender's mailbox address syntax:(RFC 3463)
111             # The sender's address was syntactically invalid. This can apply
112             # to any field in the address.
113             #
114             # X.1.8 451 Bad sender's system address:(RFC 3463)
115             # 501 The sender's system specified in the address does not exist or
116             # is incapable of accepting return mail. For domain names, this
117             # means the address portion to the right of the "@" is invalid
118             # for mail.
119             #
120             # X.1.9 --- Message relayed to non-compliant mailer:(RFC 5248, 3886)
121             # The mailbox address specified was valid, but the message has
122             # been relayed to a system that does not speak this protocol;
123             # no further information can be provided.
124             #
125             # X.1.10 --- Recipient address has null MX:(RFC 7505)
126             # This status code is returned when the associated address is
127             # marked as invalid using a null MX.
128             # ------------------------------------------------------------------------------
129             # X.2.0 --- Other or undefined mailbox status:(RFC 3463)
130             # The mailbox exists, but something about the destination mailbox
131             # has caused the sending of this DSN.
132             #
133             # X.2.1 --- Mailbox disabled, not accepting messages:(RFC 3463)
134             # The mailbox exists, but is not accepting messages. This may be
135             # a permanent error if the mailbox will never be re-enabled or a
136             # transient error if the mailbox is only temporarily disabled.
137             #
138             # X.2.2 552 Mailbox full:(RFC 3463)
139             # The mailbox is full because the user has exceeded a per-mailbox
140             # administrative quota or physical capacity. The general semantics
141             # implies that the recipient can delete messages to make more
142             # space available.
143             # This code should be used as a persistent transient failure.
144             #
145             # X.2.3 552 Message length exceeds administrative limit:(RFC 3463)
146             # A per-mailbox administrative message length limit has been
147             # exceeded. This status code should be used when the per-mailbox
148             # message length limit is less than the general system limit.
149             # This code should be used as a permanent failure.
150             #
151             # X.2.4 450 Mailing list expansion problem:(RFC 3463)
152             # 452 The mailbox is a mailing list address and the mailing list was
153             # unable to be expanded. This code may represent a permanent
154             # failure or a persistent transient failure.
155             # ------------------------------------------------------------------------------
156             # X.3.0 221 Other or undefined mail system status:(RFC 3463)
157             # 250 The destination system exists and normally accepts mail, but
158             # 421,451 something about the system has caused the generation of this
159             # 550,554 DSN.
160             #
161             # X.3.1 452 Mail system full:(RFC 3463)
162             # Mail system storage has been exceeded. The general semantics
163             # imply that the individual recipient may not be able to delete
164             # material to make room for additional messages. This is useful
165             # only as a persistent transient error.
166             #
167             # X.3.2 453 System not accepting network messages:(RFC 3463)
168             # 521 The host on which the mailbox is resident is not accepting messages.
169             # Examples of such conditions include an imminent shutdown, excessive
170             # load, or system maintenance. This is useful for both permanent
171             # and persistent transient errors.
172             #
173             # X.3.3 --- System not capable of selected features:(RFC 3463)
174             # Selected features specified for the message are not supported
175             # by the destination system. This can occur in gateways when
176             # features from one domain cannot be mapped onto the supported
177             # feature in another.
178             #
179             # X.3.4 552 Message too big for system:(RFC 3463)
180             # 554 The message is larger than per-message size limit. This limit
181             # may either be for physical or administrative reasons. This is
182             # useful only as a permanent error.
183             #
184             # X.3.5 --- System incorrectly configured:(RFC 3463)
185             # The system is not configured in a manner that will permit it
186             # to accept this message.
187             # ------------------------------------------------------------------------------
188             # X.4.0 --- Other or undefined network or routing status:(RFC 3463)
189             # Something went wrong with the networking, but it is not clear
190             # what the problem is, or the problem cannot be well expressed
191             # with any of the other provided detail codes.
192             #
193             # X.4.1 451 No answer from host:(RFC 3463)
194             # The outbound connection attempt was not answered, because either
195             # the remote system was busy, or was unable to take a call.
196             # This is useful only as a persistent transient error.
197             #
198             # X.4.2 421 Bad connection:(RFC 3463)
199             # The outbound connection was established, but was unable to
200             # complete the message transaction, either because of time-out,
201             # or inadequate connection quality. This is useful only as a
202             # persistent transient error.
203             #
204             # X.4.3 451 Directory server failure:(RFC 3463)
205             # 550 The network system was unable to forward the message, because
206             # a directory server was unavailable. This is useful only as a
207             # persistent transient error. The inability to connect to an
208             # Internet DNS server is one example of the directory server
209             # failure error.
210             #
211             # X.4.4 --- Unable to route:(RFC 3463)
212             # The mail system was unable to determine the next hop for the
213             # message because the necessary routing information was unavailable
214             # from the directory server. This is useful for both permanent
215             # and persistent transient errors. A DNS lookup returning only
216             # an SOA (Start of Administration) record for a domain name is
217             # one example of the unable to route error.
218             #
219             # X.4.5 451 Mail system congestion:(RFC 3463)
220             # The mail system was unable to deliver the message because the
221             # mail system was congested. This is useful only as a persistent
222             # transient error.
223             #
224             # X.4.6 --- Routing loop detected:(RFC 3463)
225             # A routing loop caused the message to be forwarded too many times,
226             # either because of incorrect routing tables or a user-forwarding
227             # loop. This is useful only as a persistent transient error.
228             #
229             # X.4.7 --- Delivery time expired:(RFC 3463)
230             # The message was considered too old by the rejecting system,
231             # either because it remained on that host too long or because
232             # the time-to-live value specified by the sender of the message
233             # was exceeded. If possible, the code for the actual problem
234             # found when delivery was attempted should be returned rather
235             # than this code.
236             # ------------------------------------------------------------------------------
237             # X.5.0 220 Other or undefined protocol status:(RFC 3463)
238             # 250-253 Something was wrong with the protocol necessary to deliver the
239             # 451,452 message to the next hop and the problem cannot be well expressed
240             # 454,458 with any of the other provided detail codes.
241             # 459,554
242             # 501-503
243             #
244             # X.5.1 430 Invalid command:(RFC 3463)
245             # 500,501 A mail transaction protocol command was issued which was either
246             # 503,530 out of sequence or unsupported.
247             # 550,554 This is useful only as a permanent error.
248             # 555
249             #
250             # X.5.2 500 Syntax error:(RFC 3463)
251             # 500,501 A mail transaction protocol command was issued which could not
252             # 502,550 be interpreted, either because the syntax was wrong or the
253             # 555 command is unrecognized.
254             # This is useful only as a permanent error.
255             #
256             # X.5.3 451 Too many recipients:(RFC 3463)
257             # More recipients were specified for the message than could have
258             # been delivered by the protocol. This error should normally result
259             # in the segmentation of the message into two, the remainder of
260             # the recipients to be delivered on a subsequent delivery attempt.
261             # It is included in this list in the event that such segmentation
262             # is not possible.
263             #
264             # X.5.4 451 Invalid command arguments:(RFC 3463)
265             # 501-504 A valid mail transaction protocol command was issued with
266             # 550 invalid arguments, either because the arguments were out of
267             # 555 range or represented unrecognized features.
268             # This is useful only as a permanent error.
269             #
270             # X.5.5 --- Wrong protocol version:(RFC 3463)
271             # A protocol version mis-match existed which could not be
272             # automatically resolved by the communicating parties.
273             #
274             # X.5.6 550 Authentication Exchange line is too long (RFC 4954)
275             # This enhanced status code SHOULD be returned when the server
276             # fails the AUTH command due to the client sending a [BASE64]
277             # response which is longer than the maximum buffer size available
278             # for the currently selected SASL mechanism. This is useful for
279             # both permanent and persistent transient errors.
280             # ------------------------------------------------------------------------------
281             # X.6.0 --- Other or undefined media error:(RFC 3463)
282             # Something about the content of a message caused it to be considered
283             # undeliverable and the problem cannot be well expressed with
284             # any of the other provided detail codes.
285             #
286             # X.6.1 --- Media not supported:(RFC 3463)
287             # The media of the message is not supported by either the delivery
288             # protocol or the next system in the forwarding path. This is
289             # useful only as a permanent error.
290             #
291             # X.6.2 --- Conversion required and prohibited:(RFC 3463)
292             # The content of the message must be converted before it can be
293             # delivered and such conversion is not permitted. Such prohibitions
294             # may be the expression of the sender in the message itself or
295             # the policy of the sending host.
296             #
297             # X.6.3 554 Conversion required but not supported:(RFC 3463)
298             # The message content must be converted in order to be forwarded
299             # but such conversion is not possible or is not practical by a
300             # host in the forwarding path. This condition may result when
301             # an ESMTP gateway supports 8bit transport but is not able to
302             # downgrade the message to 7 bit as required for the next hop.
303             #
304             # X.6.4 250 Conversion with loss performed:(RFC 3463)
305             # This is a warning sent to the sender when message delivery was
306             # successfully but when the delivery required a conversion in
307             # which some data was lost. This may also be a permanent error
308             # if the sender has indicated that conversion with loss is
309             # prohibited for the message.
310             #
311             # X.6.5 --- Conversion Failed:(RFC 3463)
312             # A conversion was required but was unsuccessful. This may be
313             # useful as a permanent or persistent temporary notification.
314             #
315             # X.6.6 554 Message content not available (RFC 4468)
316             # The message content could not be fetched from a remote system.
317             # This may be useful as a permanent or persistent temporary
318             # notification.
319             #
320             # X.6.7 553 The ALT-ADDRESS is required but not specified:(RFC 6531)
321             # 550 This indicates the reception of a MAIL or RCPT command that
322             # non-ASCII addresses are not permitted
323             #
324             # X.6.8 252 UTF-8 string reply is required, but not permitted by the client:(RFC 6531)
325             # 553 This indicates that a reply containing a UTF-8 string is required
326             # 550 to show the mailbox name, but that form of response is not permitted
327             # by the SMTP client.
328             #
329             # X.6.9 550 UTF8SMTP downgrade failed:(RFC 6531)
330             # This indicates that transaction failed after the final "." of
331             # the DATA command.
332             #
333             # X.6.10 This is a duplicate of X.6.8 and is thus deprecated.
334             # ------------------------------------------------------------------------------
335             # X.7.0 220 Other or undefined security status:(RFC 3463)
336             # 235 Something related to security caused the message to be returned,
337             # 450,454 and the problem cannot be well expressed with any of the other
338             # 500,501 provided detail codes. This status code may also be used when
339             # 503,504 the condition cannot be further described because of security
340             # 530,535 policies in force.
341             # 550
342             #
343             # X.7.1 451 Delivery not authorized, message refused:(RFC 3463)
344             # 454,502 The sender is not authorized to send to the destination. This
345             # 503,533 can be the result of per-host or per-recipient filtering. This
346             # 550,551 memo does not discuss the merits of any such filtering, but
347             # provides a mechanism to report such. This is useful only as
348             # a permanent error.
349             #
350             # X.7.2 550 Mailing list expansion prohibited:(RFC 3463)
351             # The sender is not authorized to send a message to the intended
352             # mailing list. This is useful only as a permanent error.
353             #
354             # X.7.3 --- Security conversion required but not possible:(RFC 3463)
355             # A conversion from one secure messaging protocol to another was
356             # required for delivery and such conversion was not possible.
357             # This is useful only as a permanent error.
358             #
359             # X.7.4 504 Security features not supported:(RFC 3463)
360             # A message contained security features such as secure authentication
361             # that could not be supported on the delivery protocol. This is
362             # useful only as a permanent error.
363             #
364             # X.7.5 --- Cryptographic failure:(RFC 3463)
365             # A transport system otherwise authorized to validate or decrypt
366             # a message in transport was unable to do so because necessary
367             # information such as key was not available or such information
368             # was invalid.
369             #
370             # X.7.6 --- Cryptographic algorithm not supported:(RFC 3463)
371             # A transport system otherwise authorized to validate or decrypt
372             # a message was unable to do so because the necessary algorithm
373             # was not supported.
374              
375             # X.7.7 --- Message integrity failure:(RFC 3463)
376             # A transport system otherwise authorized to validate a message
377             # was unable to do so because the message was corrupted or altered.
378             # This may be useful as a permanent, transient persistent, or
379             # successful delivery code.
380             #
381             # X.7.8 535 Trust relationship required:(RFC 4954)
382             # 554 This response to the AUTH command indicates that the authentication
383             # failed due to invalid or insufficient authentication credentials.
384             # In this case, the client SHOULD ask the user to supply new credentials
385             # (such as by presenting a password dialog box).
386             #
387             # X.7.9 534 Authentication mechanism is too weak:(RFC 4954)
388             # This response to the AUTH command indicates that the selected
389             # authentication mechanism is weaker than server policy permits
390             # for that user. The client SHOULD retry with a new authentication
391             # mechanism.
392             #
393             # X.7.10 523 Encryption Needed:(RFC 5248)
394             # This indicates that external strong privacy layer is needed in
395             # order to use the requested authentication mechanism. This is
396             # primarily intended for use with clear text authentication mechanisms.
397             # A client which receives this may activate a security layer such
398             # as TLS prior to authenticating, or attempt to use a stronger
399             # mechanism.
400             #
401             # X.7.11 524 Encryption required for requested authentication mechanism:(RFC 4954)
402             # 538 This response to the AUTH command indicates that the selected
403             # authentication mechanism may only be used when the underlying
404             # SMTP connection is encrypted. Note that this response code is
405             # documented here for historical purposes only. Modern implementations
406             # SHOULD NOT advertise mechanisms that are not permitted due to
407             # lack of encryption, unless an encryption layer of sufficient
408             # strength is currently being employed.
409             #
410             # X.7.12 422 A password transition is needed:(RFC 4954)
411             # 432 This response to the AUTH command indicates that the user needs
412             # to transition to the selected authentication mechanism. This
413             # is typically done by authenticating once using the [PLAIN]
414             # authentication mechanism. The selected mechanism SHOULD then
415             # work for authentications in subsequent sessions.
416             #
417             # X.7.13 525 User Account Disabled:(RFC 5248)
418             # Sometimes a system administrator will have to disable a user's
419             # account (e.g., due to lack of payment, abuse, evidence of a
420             # break-in attempt, etc).
421             # This error code occurs after a successful authentication to a
422             # disabled account. This informs the client that the failure is
423             # permanent until the user contacts their system administrator
424             # to get the account re-enabled.
425             # It differs from a generic authentication failure where the
426             # client's best option is to present the passphrase entry dialog
427             # in case the user simply mistyped their passphrase.
428             #
429             # X.7.14 535 Trust relationship required:(RFC 5248)
430             # 554 The submission server requires a configured trust relationship
431             # with a third-party server in order to access the message content.
432             # This value replaces the prior use of X.7.8 for this error condition.
433             # thereby updating [RFC4468].
434             #
435             # X.7.15 450 Priority Level is too low:(RFC6710)
436             # 550 The specified priority level is below the lowest priority acceptable
437             # 4xx for the receiving SMTP server. This condition might be temporary,
438             # 5xx for example the server is operating in a mode where only higher
439             # priority messages are accepted for transfer and delivery, while
440             # lower priority messages are rejected.
441             #
442             # X.7.16 552 Message is too big for the specified priority:(RFC 6710)
443             # 4xx The message is too big for the specified priority.
444             # 5xx This condition might be temporary, for example the server is
445             # operating in a mode where only higher priority messages below
446             # certain size are accepted for transfer and delivery.
447             #
448             # X.7.17 5xx Mailbox owner has changed:(RFC 6710)
449             # This status code is returned when a message is received with
450             # a Require-Recipient-Valid-Since field or RRVS extension and
451             # the receiving system is able to determine that the intended
452             # recipient mailbox has not been under continuous ownership since
453             # the specified date-time.
454             #
455             # X.7.18 5xx Domain owner has changed:(RFC 7293)
456             # This status code is returned when a message is received with
457             # a Require-Recipient-Valid-Since field or RRVS extension and
458             # the receiving system wishes to disclose that the owner of the
459             # domain name of the recipient has changed since the specified
460             # date-time.
461             #
462             # X.7.19 5xx RRVS test cannot be completed:(RFC 7293)
463             # This status code is returned when a message is received with
464             # a Require-Recipient-Valid-Since field or RRVS extension and
465             # the receiving system cannot complete the requested evaluation
466             # because the required timestamp was not recorded.
467             # The message originator needs to decide whether to reissue the
468             # message without RRVS protection.
469             #
470             # X.7.20 550 No passing DKIM signature found:(RFC 7372)
471             # This status code is returned when a message did not contain
472             # any passing DKIM signatures. (This violates the advice of
473             # Section 6.1 of [RFC6376].)
474             #
475             # X.7.21 550 No acceptable DKIM signature found:(RFC 7372, 6476)
476             # This status code is returned when a message contains one or
477             # more passing DKIM signatures, but none are acceptable.
478             # (This violates the advice of Section 6.1 of [RFC6376].)
479             #
480             # X.7.22 550 No valid author-matched DKIM signature found:(RFC 7372)
481             # This status code is returned when a message contains one or
482             # more passing DKIM signatures, but none are acceptable because
483             # none have an identifier(s) that matches the author address(es)
484             # found in the From header field.
485             # This is a special case of X.7.21. (This violates the advice of
486             # Section 6.1 of [RFC6376].)
487             #
488             # X.7.23 550 SPF validation failed:(RFC 7273, 7208)
489             # This status code is returned when a message completed an SPF
490             # check that produced a "fail" result, contrary to local policy
491             # requirements. Used in place of 5.7.1 as described in Section
492             # 8.4 of [RFC7208].
493             #
494             # X.7.24 451 SPF validation error:(RFC 7372, 7208)
495             # 550 This status code is returned when evaluation of SPF relative
496             # to an arriving message resulted in an error. Used in place of
497             # 4.4.3 or 5.5.2 as described in Sections 8.6 and 8.7 of [RFC7208].
498             #
499             # X.7.25 550 Reverse DNS validation failed:(RFC 7372, 7601)
500             # This status code is returned when an SMTP client's IP address
501             # failed a reverse DNS validation check, contrary to local policy
502             # requirements.
503             #
504             # X.7.26 550 Multiple authentication checks failed:(RFC 7372)
505             # This status code is returned when a message failed more than
506             # one message authentication check, contrary to local policy
507             # requirements. The particular mechanisms that failed are not
508             # specified.
509             #
510             # X.7.27 550 Sender address has null MX:(RFC 7505)
511             # This status code is returned when the associated sender address
512             # has a null MX, and the SMTP receiver is configured to reject
513             # mail from such sender (e.g., because it could not return a DSN).
514             # ------------------------------------------------------------------------------
515             # SAMPLES
516             #
517             # 554 5.5.0 No recipients have been specified
518             # 503 5.5.0 Valid RCPT TO required before BURL
519             # 554 5.6.3 Conversion required but not supported
520             # 554 5.3.4 Message too big for system
521             # 554 5.7.8 URL resolution requires trust relationship
522             # 552 5.2.2 Mailbox full
523             # 554 5.6.6 IMAP URL resolution failed
524             # 250 2.5.0 Waiting for additional BURL or BDAT commands
525             # 451 4.4.1 IMAP server unavailable
526             # 250 2.5.0 Ok.
527             # 250 2.6.4 MIME header conversion with loss performed
528             # 235 2.7.0 Authentication Succeeded
529             # 432 4.7.12 A password transition is needed
530             # 454 4.7.0 Temporary authentication failure
531             # 534 5.7.9 Authentication mechanism is too weak
532             # 535 5.7.8 Authentication credentials invalid
533             # 500 5.5.6 Authentication Exchange line is too long
534             # 530 5.7.0 Authentication required
535             # 538 5.7.11 Encryption required for requested authentication
536             # 5.7.8 Authentication credentials invalid
537             # 5.7.9 Authentication mechanism is too weak
538             # 5.7.11 Encryption required for requested authentication mechanism
539             # ------------------------------------------------------------------------------
540             #
541 80         18620 use constant StandardCode => {
542             '2.1.5' => 'delivered', # Successfully delivered
543             # ------------------------------------------------------------------------------
544             '4.1.6' => 'hasmoved', # Destination mailbox has moved, No forwarding address
545             '4.1.7' => 'rejected', # Bad sender's mailbox address syntax
546             '4.1.8' => 'rejected', # Bad sender's system address
547             '4.1.9' => 'systemerror', # Message relayed to non-compliant mailer
548             '4.2.1' => 'suspend', # Mailbox disabled, not accepting messages
549             '4.2.2' => 'mailboxfull', # Mailbox full
550             '4.2.3' => 'exceedlimit', # Message length exceeds administrative limit
551             '4.2.4' => 'filtered', # Mailing list expansion problem
552             #'4.3.0' => 'systemerror', # Other or undefined mail system status
553             '4.3.1' => 'systemfull', # Mail system full
554             '4.3.2' => 'notaccept', # System not accepting network messages
555             '4.3.3' => 'systemerror', # System not capable of selected features
556             '4.3.5' => 'systemerror', # System incorrectly configured
557             #'4.4.0' => 'networkerror', # Other or undefined network or routing status
558             '4.4.1' => 'expired', # No answer from host
559             '4.4.2' => 'networkerror', # Bad connection
560             #'4.4.3' => 'systemerror', # Directory server failure
561             '4.4.4' => 'networkerror', # Unable to route
562             '4.4.5' => 'systemfull', # Mail system congestion
563             '4.4.6' => 'networkerror', # Routing loop detected
564             '4.4.7' => 'expired', # Delivery time expired
565             #'4.5.0' => 'networkerror', # Other or undefined protocol status
566             '4.5.3' => 'systemerror', # Too many recipients
567             '4.5.5' => 'systemerror', # Wrong protocol version
568             '4.6.0' => 'contenterror', # Other or undefined media error
569             '4.6.2' => 'contenterror', # Conversion required and prohibited
570             '4.6.5' => 'contenterror', # Conversion Failed
571             #'4.7.0' => 'securityerror',# Other or undefined security status
572             '4.7.1' => 'blocked', # Delivery not authorized, message refused
573             '4.7.2' => 'blocked', # Mailing list expansion prohibited
574             '4.7.5' => 'securityerror',# Cryptographic failure
575             '4.7.6' => 'securityerror',# Cryptographic algorithm not supported
576             '4.7.7' => 'securityerror',# Message integrity failure
577             '4.7.12' => 'securityerror',# A password transition is needed
578             '4.7.15' => 'securityerror',# Priority Level is too low
579             '4.7.16' => 'mesgtoobig', # Message is too big for the specified priority
580             '4.7.24' => 'securityerror',# SPF validation error
581             '4.7.25' => 'blocked', # Reverse DNS validation failed
582             # ------------------------------------------------------------------------------
583             '5.1.0' => 'userunknown', # Other address status
584             '5.1.1' => 'userunknown', # Bad destination mailbox address
585             '5.1.2' => 'hostunknown', # Bad destination system address
586             '5.1.3' => 'userunknown', # Bad destination mailbox address syntax
587             '5.1.4' => 'filtered', # Destination mailbox address ambiguous
588             '5.1.6' => 'hasmoved', # Destination mailbox has moved, No forwarding address
589             '5.1.7' => 'rejected', # Bad sender's mailbox address syntax
590             '5.1.8' => 'rejected', # Bad sender's system address
591             '5.1.9' => 'systemerror', # Message relayed to non-compliant mailer
592             '5.1.10' => 'notaccept', # Recipient address has null MX
593             '5.2.0' => 'filtered', # Other or undefined mailbox status
594             '5.2.1' => 'filtered', # Mailbox disabled, not accepting messages
595             '5.2.2' => 'mailboxfull', # Mailbox full
596             '5.2.3' => 'exceedlimit', # Message length exceeds administrative limit
597             '5.2.4' => 'filtered', # Mailing list expansion problem
598             '5.3.0' => 'systemerror', # Other or undefined mail system status
599             '5.3.1' => 'systemfull', # Mail system full
600             '5.3.2' => 'notaccept', # System not accepting network messages
601             '5.3.3' => 'systemerror', # System not capable of selected features
602             '5.3.4' => 'mesgtoobig', # Message too big for system
603             '5.3.5' => 'systemerror', # System incorrectly configured
604             '5.4.0' => 'networkerror', # Other or undefined network or routing status
605             '5.4.3' => 'systemerror', # Directory server failure
606             '5.4.4' => 'hostunknown', # Unable to route
607             '5.5.3' => 'toomanyconn', # Too many recipients
608             '5.5.4' => 'systemerror', # Invalid command arguments
609             '5.5.5' => 'systemerror', # Wrong protocol version
610             '5.5.6' => 'securityerror',# Authentication Exchange line is too long
611             '5.6.0' => 'contenterror', # Other or undefined media error
612             '5.6.1' => 'contenterror', # Media not supported
613             '5.6.2' => 'contenterror', # Conversion required and prohibited
614             '5.6.3' => 'contenterror', # Conversion required but not supported
615             '5.6.5' => 'contenterror', # Conversion Failed
616             '5.6.6' => 'contenterror', # Message content not available
617             '5.6.7' => 'contenterror', # Non-ASCII addresses not permitted for that sender/recipient
618             '5.6.8' => 'contenterror', # UTF-8 string reply is required, but not permitted by the SMTP client
619             '5.6.9' => 'contenterror', # UTF-8 header message cannot be transferred to one or more recipients
620             '5.7.0' => 'securityerror',# Other or undefined security status
621             '5.7.1' => 'securityerror',# Delivery not authorized, message refused
622             '5.7.2' => 'securityerror',# Mailing list expansion prohibited
623             '5.7.3' => 'securityerror',# Security conversion required but not possible
624             '5.7.4' => 'securityerror',# Security features not supported
625             '5.7.5' => 'securityerror',# Cryptographic failure
626             '5.7.6' => 'securityerror',# Cryptographic algorithm not supported
627             '5.7.7' => 'securityerror',# Message integrity failure
628             '5.7.8' => 'securityerror',# Authentication credentials invalid
629             '5.7.9' => 'securityerror',# Authentication mechanism is too weak
630             '5.7.10' => 'securityerror',# Encryption Needed
631             '5.7.11' => 'securityerror',# Encryption required for requested authentication mechanism
632             '5.7.13' => 'suspend', # User Account Disabled
633             '5.7.14' => 'securityerror',# Trust relationship required
634             '5.7.15' => 'securityerror',# Priority Level is too low
635             '5.7.16' => 'mesgtoobig', # Message is too big for the specified priority
636             '5.7.17' => 'hasmoved', # Mailbox owner has changed
637             '5.7.18' => 'hasmoved', # Domain owner has changed
638             '5.7.19' => 'securityerror',# RRVS test cannot be completed
639             '5.7.20' => 'securityerror',# No passing DKIM signature found
640             '5.7.21' => 'securityerror',# No acceptable DKIM signature found
641             '5.7.22' => 'securityerror',# No valid author-matched DKIM signature found
642             '5.7.23' => 'securityerror',# SPF validation failed
643             '5.7.24' => 'securityerror',# SPF validation error
644             '5.7.25' => 'blocked', # Reverse DNS validation failed
645             '5.7.26' => 'securityerror',# Multiple authentication checks failed
646             '5.7.27' => 'notaccept', # MX resource record of a destination host is Null MX: RFC7505
647 80     80   608 };
  80         183  
648              
649 80         42788 use constant InternalCode => {
650             'temporary' => {
651             'blocked' => '4.0.971',
652             'contenterror' => '4.0.960',
653             #'exceedlimit' => '4.0.923',
654             'expired' => '4.0.947',
655             'filtered' => '4.0.924',
656             #'hasmoved' => '4.0.916',
657             #'hostunknown' => '4.0.912',
658             'mailboxfull' => '4.0.922',
659             #'mailererror' => '4.0.939',
660             #'mesgtoobig' => '4.0.934',
661             'networkerror' => '4.0.944',
662             #'norelaying' => '4.0.909',
663             'notaccept' => '4.0.932',
664             'onhold' => '4.0.901',
665             'rejected' => '4.0.918',
666             'securityerror'=> '4.0.970',
667             'spamdetected' => '4.0.980',
668             #'suspend' => '4.0.921',
669             'systemerror' => '4.0.930',
670             'systemfull' => '4.0.931',
671             'toomanyconn' => '4.0.945',
672             #'userunknown' => '4.0.911',
673             'undefined' => '4.0.900',
674             },
675             'permanent' => {
676             'blocked' => '5.0.971',
677             'contenterror' => '5.0.960',
678             'exceedlimit' => '5.0.923',
679             'expired' => '5.0.947',
680             'filtered' => '5.0.910',
681             'hasmoved' => '5.0.916',
682             'hostunknown' => '5.0.912',
683             'mailboxfull' => '5.0.922',
684             'mailererror' => '5.0.939',
685             'mesgtoobig' => '5.0.934',
686             'networkerror' => '5.0.944',
687             'norelaying' => '5.0.909',
688             'notaccept' => '5.0.932',
689             'onhold' => '5.0.901',
690             'policyviolation'=> '5.0.972',
691             'rejected' => '5.0.918',
692             'securityerror' => '5.0.970',
693             'spamdetected' => '5.0.980',
694             'suspend' => '5.0.921',
695             'systemerror' => '5.0.930',
696             'systemfull' => '5.0.931',
697             'syntaxerror' => '5.0.902',
698             'toomanyconn' => '5.0.945',
699             'userunknown' => '5.0.911',
700             'undefined' => '5.0.900',
701             'virusdetected' => '5.0.971',
702             },
703 80     80   573 };
  80         217  
704              
705             sub code {
706             # Convert from the reason string to the internal status code
707             # @param [String] argv1 Reason name
708             # @param [Integer] argv2 0: Permanent error
709             # 1: Temporary error
710             # @return [String] D.S.N. or empty if the 1st argument is missing
711             # @see name
712             # @since v4.14.0
713 810     810 1 30538 my $class = shift;
714 810   100     2005 my $argv1 = shift || return undef;
715 754   100     1810 my $argv2 = shift // 0;
716 754         1025 my $table = undef;
717 754         996 my $code0 = undef;
718              
719 754 100       1865 $table = $argv2 ? InternalCode->{'temporary'} : InternalCode->{'permanent'};
720 754   66     2070 $code0 = $table->{ $argv1 } // InternalCode->{'permanent'}->{ $argv1 } // '';
      50        
721 754         3155 return $code0;
722             }
723              
724             sub name {
725             # Convert from the status code to the reason string
726             # @param [String] state Status code(DSN)
727             # @return [String] Reason name or empty if the first argument did
728             # not match with values in Sisimai's reason list
729             # @see code
730             # @since v4.14.0
731 11812     11812 1 59188 my $class = shift;
732 11812   100     25866 my $argv1 = shift || return undef;
733              
734 9849 50       34459 return '' unless $argv1 =~ /\A[245][.]\d[.]\d+\z/;
735 9849   100     50589 return StandardCode->{ $argv1 } // '';
736             }
737              
738             sub find {
739             # Get a DSN code value from given string including DSN
740             # @param [String] argv1 String including DSN
741             # @return [String] DSN or empty string if the first agument did
742             # not include DSN
743             # @since v4.14.0
744 4263     4263 1 13420 my $class = shift;
745 4263   100     8930 my $argv1 = shift || return undef;
746 4257         6229 my $found = '';
747              
748 4257         5781 state $regularexp = [
749             qr/[ ]?[(][#]([45][.]\d[.]\d+)[)]?[ ]?/, # #5.5.1
750             qr/\b\d{3}[ -][#]?([45][.]\d[.]\d+)\b/, # 550-5.1.1 OR 550 5.5.1
751             qr/\b([45][.]\d[.]\d+)\b/, # 5.5.1
752             qr/\b(2[.][0-7][.][0-7])\b/, # 2.1.5
753             ];
754              
755 4257         7022 for my $e ( @$regularexp ) {
756             # Get the value of DSN in the text
757 13696 100       60101 next unless $argv1 =~ $e;
758 1722         4203 $found = $1;
759              
760 1722 50       58063 if( $argv1 =~ /\b(?:${found}[.]\d{1,3}|\d{1,3}[.]${found})\b/ ) {
761             # Clear and skip if the value is an IPv4 address
762 0         0 $found = '';
763 0         0 next;
764             }
765 1722         4329 last;
766             }
767 4257         14881 return $found;
768             }
769              
770             1;
771             __END__