| 1 | package Sisimai::Rhost::Facebook; | ||||||||||||
| 2 | 5 | ▶ | use v5.26; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 17 | ▶ | sub find { | ||||||||||
|
Subroutine
find: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 7 | # Detect bounce reason for Facebook | ||||||||||||
| 8 | # @param [Sisimai::Fact] argvs Decoded email object | ||||||||||||
| 9 | # @return [String] Detected bounce reason | ||||||||||||
| 10 | # @see https://www.facebook.com/postmaster/response_codes | ||||||||||||
| 11 | # @since v5.2.0 | ||||||||||||
| 12 | 17 | my $class = shift; | |||||||||||
| 13 | 17 | ▶ | my $argvs = shift // return ""; | ||||||||||
|
Condition100%2/2
shift() // (return "")
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 14 | 16 | ▶ | return "" unless $argvs->{'diagnosticcode'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 15 | 15 | ▶ | return "" unless index($argvs->{'diagnosticcode'}, '-'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | |||||||||||||
| 17 | 15 | require Sisimai::Eb; | |||||||||||
| 18 | 15 | state $errorcodes = { | |||||||||||
| 19 | # http://postmaster.facebook.com/response_codes | ||||||||||||
| 20 | # NOT TESTD EXCEPT RCP-P2 | ||||||||||||
| 21 | $Sisimai::Eb::ReAUTH => [ | ||||||||||||
| 22 | "POL-P7", # The message does not comply with Facebook's Domain Authentication requirements. | ||||||||||||
| 23 | ], | ||||||||||||
| 24 | $Sisimai::Eb::ReBLOC => [ | ||||||||||||
| 25 | "POL-P1", # Your mail server's IP Address is listed on the Spamhaus PBL. | ||||||||||||
| 26 | "POL-P2", # Facebook will no longer accept mail from your mail server's IP Address. | ||||||||||||
| 27 | "POL-P3", # Facebook is not accepting messages from your mail server. This will persist for 4 to 8 hours. | ||||||||||||
| 28 | "POL-P4", # ". This will persist for 24 to 48 hours. | ||||||||||||
| 29 | "POL-T1", # ", but they may be retried later. This will persist for 1 to 2 hours. | ||||||||||||
| 30 | "POL-T2", # ", but they may be retried later. This will persist for 4 to 8 hours. | ||||||||||||
| 31 | "POL-T3", # ", but they may be retried later. This will persist for 24 to 48 hours. | ||||||||||||
| 32 | ], | ||||||||||||
| 33 | $Sisimai::Eb::ReBODY => [ | ||||||||||||
| 34 | "MSG-P2", # The message contains an attachment type that Facebook does not accept. | ||||||||||||
| 35 | ], | ||||||||||||
| 36 | $Sisimai::Eb::ReSIZE => [ | ||||||||||||
| 37 | "MSG-P1", # The message exceeds Facebook's maximum allowed size. | ||||||||||||
| 38 | "INT-P2", # The message exceeds Facebook's maximum allowed size. | ||||||||||||
| 39 | ], | ||||||||||||
| 40 | $Sisimai::Eb::ReFILT => [ | ||||||||||||
| 41 | "RCP-P2", # The attempted recipient's preferences prevent messages from being delivered. | ||||||||||||
| 42 | "RCP-P3", # The attempted recipient's privacy settings blocked the delivery. | ||||||||||||
| 43 | ], | ||||||||||||
| 44 | $Sisimai::Eb::ReFULL => [ | ||||||||||||
| 45 | "INT-P7", # The attempted recipient has exceeded their storage quota. | ||||||||||||
| 46 | ], | ||||||||||||
| 47 | $Sisimai::Eb::ReWONT => [ | ||||||||||||
| 48 | "POL-P8", # The message does not comply with Facebook's abuse policies and will not be accepted. | ||||||||||||
| 49 | ], | ||||||||||||
| 50 | $Sisimai::Eb::ReNRFC => [ | ||||||||||||
| 51 | "MSG-P3", # The message contains multiple instances of a header field that can only be present once. | ||||||||||||
| 52 | ], | ||||||||||||
| 53 | $Sisimai::Eb::ReRATE => [ | ||||||||||||
| 54 | "CON-T1", # Facebook's mail server currently has too many connections open to allow another one. | ||||||||||||
| 55 | "CON-T2", # Your mail server currently has too many connections open to Facebook's mail servers. | ||||||||||||
| 56 | "CON-T3", # Your mail server has opened too many new connections to Facebook's mail servers in a short period of time. | ||||||||||||
| 57 | "CON-T4", # Your mail server has exceeded the maximum number of recipients for its current connection. | ||||||||||||
| 58 | "MSG-T1", # The number of recipients on the message exceeds Facebook's allowed maximum. | ||||||||||||
| 59 | ], | ||||||||||||
| 60 | $Sisimai::Eb::ReFROM => [ | ||||||||||||
| 61 | "DNS-P1", # Your SMTP MAIL FROM domain does not exist. | ||||||||||||
| 62 | "DNS-P2", # Your SMTP MAIL FROM domain does not have an MX record. | ||||||||||||
| 63 | "DNS-T1", # Your SMTP MAIL FROM domain exists but does not currently resolve. | ||||||||||||
| 64 | ], | ||||||||||||
| 65 | $Sisimai::Eb::ReQPTR => [ | ||||||||||||
| 66 | "DNS-P3", # Your mail server does not have a reverse DNS record. | ||||||||||||
| 67 | "DNS-T2", # You mail server's reverse DNS record does not currently resolve. | ||||||||||||
| 68 | ], | ||||||||||||
| 69 | $Sisimai::Eb::ReSPAM => [ | ||||||||||||
| 70 | "POL-P6", # The message contains a url that has been blocked by Facebook. | ||||||||||||
| 71 | ], | ||||||||||||
| 72 | $Sisimai::Eb::ReQUIT => [ | ||||||||||||
| 73 | "RCP-T4", # The attempted recipient address is currently deactivated. The user may or may not reactivate it. | ||||||||||||
| 74 | ], | ||||||||||||
| 75 | $Sisimai::Eb::RePROC => [ | ||||||||||||
| 76 | "RCP-T1", # The attempted recipient address is not currently available due to an internal system issue. | ||||||||||||
| 77 | "INT-Tx", # These codes indicate a temporary issue internal to Facebook's system. | ||||||||||||
| 78 | ], | ||||||||||||
| 79 | $Sisimai::Eb::ReUSER => [ | ||||||||||||
| 80 | "RCP-P1", # The attempted recipient address does not exist. | ||||||||||||
| 81 | "INT-P1", # The attempted recipient address does not exist. | ||||||||||||
| 82 | "INT-P3", # The attempted recipient group address does not exist. | ||||||||||||
| 83 | "INT-P4", # The attempted recipient address does not exist. | ||||||||||||
| 84 | ], | ||||||||||||
| 85 | $Sisimai::Eb::ReEXEC => [ | ||||||||||||
| 86 | "POL-P5", # The message contains a virus. | ||||||||||||
| 87 | ], | ||||||||||||
| 88 | }; | ||||||||||||
| 89 | 15 | my $errorindex = index($argvs->{'diagnosticcode'}, "-"); | |||||||||||
| 90 | 15 | my $errorlabel = substr($argvs->{'diagnosticcode'}, $errorindex - 3, 6); | |||||||||||
| 91 | 15 | my $reasontext = ""; | |||||||||||
| 92 | |||||||||||||
| 93 | 15 | for my $e ( keys %$errorcodes ) { | |||||||||||
| 94 | # The key is a bounce reason name | ||||||||||||
| 95 | 147 | ▶ | next unless grep { $errorlabel eq $_ } $errorcodes->{ $e }->@*; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 96 | 13 | $reasontext = $e; last | |||||||||||
| 97 | 13 | } | |||||||||||
| 98 | 15 | return $reasontext; | |||||||||||
| 99 | } | ||||||||||||
| 100 | |||||||||||||
| 101 | 5 | 1; | |||||||||||
| 102 | __END__ | ||||||||||||