File Coverage

lib/Sisimai/Rhost/Google.pm
Criterion Covered Total %
statement 26 26 100.0
branch 11 12 91.6
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 43 45 95.5


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::Google;
2 9     9   2726 use v5.26;
  9         43  
3 9     9   59 use strict;
  9         17  
  9         372  
4 9     9   77 use warnings;
  9         17  
  9         16617  
5              
6             sub find {
7             # Detect bounce reason from Google Workspace
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] The bounce reason for Google Workspace
10             # @see https://support.google.com/a/answer/3726730?hl=en
11             # @since v4.0.0
12 134     134 0 1456 my $class = shift;
13 134 100 100     495 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  133         707  
14 132 100       749 return '' unless Sisimai::SMTP::Reply->test($argvs->{'replycode'});
15 130 50       840 return '' unless Sisimai::SMTP::Status->test($argvs->{'deliverystatus'});
16              
17 130         1501 state $messagesof = {
18             'authfailure' => [
19             # - 451 4.7.24 The SPF record of the sending domain has one or more suspicious entries.
20             # To protect our users from spam, mail sent from your IP address has been temporarily
21             # rate limited. For more information, go to Email sender guidelines.
22             # https://support.google.com/mail/answer/81126#authentication
23             #
24             # - 550 5.7.24 The SPF record of the sending domain has one or more suspicious entries.
25             # For more information, go to Email sender guidelines.
26             # - https://support.google.com/mail/answer/81126#authentication
27             ['451', '4.7.24', 'the spf record of the sending domain'],
28             ['550', '5.7.24', 'the spf record of the sending domain'],
29              
30             # - 421 4.7.26 This mail has been rate limited because it is unauthenticated.
31             # Gmail requires all senders to authenticate with either SPF or DKIM.
32             # Authentication results: DKIM = did not pass SPF domain-name with ip: ip-address =
33             # did not pass. To resolve this issue, go to Email sender guidelines.
34             # - https://support.google.com/mail/answer/81126#authentication
35             ['421', '4.7.26', 'senders to authenticate with either spf or dkim'],
36             ['550', '5.7.26', 'senders to authenticate with either spf or dkim'],
37              
38             # - 550 5.7.26 This message fails to pass SPF checks for an SPF record with a hard fail
39             # policy (-all). To best protect our users from spam and phishing, the message has
40             # been blocked. Please visit https://support.google.com/mail/answer/81126 for more
41             # information.
42             #
43             # - 550 5.7.26 The MAIL FROM domain [domain-name] has an SPF record with a hard fail
44             # policy (-all) but it fails to pass SPF checks with the ip: [ip-address]. To best
45             # protect our users from spam and phishing, the message has been blocked. For more
46             # information, go to Email sender guidelines.
47             # - https://support.google.com/mail/answer/81126#authentication
48             ['550', '5.7.26', 'fails to pass spf checks for an spf record with a hard fail'],
49             ['550', '5.7.26', 'has an spf record with a hard fail policy'],
50              
51             # - 451 4.7.26 Unauthenticated email from domain-name is not accepted due to domain's
52             # DMARC policy, but temporary DNS failures prevent authentication. Please contact the
53             # administrator of domain-name domain if this was a legitimate mail. To learn about
54             # the DMARC initiative, go to https://support.google.com/mail/?p=DmarcRejection
55             ['451', '4.7.26', "is not accepted due to domain's dmarc policy"],
56             ['550', '5.7.26', "is not accepted due to domain's dmarc policy"],
57              
58             # - 550 5.7.26 Unauthenticated email from domain-name is not accepted due to domain's
59             # DMARC policy. Please contact the administrator of domain-name domain. If this was
60             # a legitimate mail please visit [Control unauthenticated mail from your domain] to
61             # learn about the DMARC initiative. If the messages are valid and aren't spam, con-
62             # tact the administrator of the receiving mail server to determine why your outgoing
63             # messages don't pass authentication checks.
64             ['550', '5.7.26', "is not accepted due to domain's dmarc policy"],
65              
66             # - 550 5.7.26 This message does not have authentication information or fails to pass
67             # authentication checks (SPF or DKIM). To best protect our users from spam, the mes-
68             # sage has been blocked. Please visit https://support.google.com/mail/answer/81126
69             # for more information.
70             ['550', '5.7.1', 'fails to pass authentication checks'],
71             ['550', '5.7.26', 'fails to pass authentication checks'],
72              
73             # - 421 4.7.27 Your email has been rate limited because SPF authentication didn't pass
74             # for this message. Gmail requires all bulk email senders to authenticate their emaili
75             # with SPF. Authentication results: SPF domain-name with IP address: ip-address = Did
76             # not pass.
77             ['421', '4.7.27', 'senders to authenticate with spf'],
78             ['421', '4.7.27', 'senders to authenticate their email with spf'],
79             ['550', '5.7.27', 'senders to authenticate with spf'],
80              
81             # - 421 4.7.30 Your email has been rate limited because DKIM authentication didn't pass
82             # for this message. Gmail requires all email bulk senders to authenticate their email
83             # with DKIM. Authentication results: DKIM = Did not pass.
84             ['421', '4.7.30', 'senders to authenticate their email with dkim'],
85              
86             # - 550 5.7.30 This mail has been blocked because DKIM does not pass. Gmail requires all
87             # large senders to authenticate with DKIM. Authentication results: DKIM = did not pass.
88             # For instructions on setting up DKIM authentication, go to Turn on DKIM for your domain.
89             ['550', '5.7.30', 'senders to authenticate with dkim'],
90              
91             # - 421 4.7.32 Your email has been rate limited because the From: header (RFC5322) in
92             # this message isn't aligned with either the authenticated SPF or DKIM organizational
93             # domain.
94             # - 421 5.7.32 Your email was blocked because the From: header (RFC5322) in this message
95             # isn't aligned with either the authenticated SPF or DKIM organizational domain.
96             ['421', '4.7.32', 'aligned with either the authenticated spf or dkim'],
97             ["421", "5.7.32", "aligned with either the authenticated spf or dkim"],
98              
99             # - 421 4.7.40 Your email has been rate limited because the sending domain doesn't
100             # have a DMARC record, or the DMARC record doesn't specify a DMARC policy. Gmail
101             # requires all bulk email senders to add a DMARC record to their sending domain.
102             # - 550 5.7.40 Your message was blocked because the sending domain doesn't have a DMARC
103             # record or the DMARC record doesn?ft specify a DMARC policy. Gmail requires all bulk
104             # email senders to add a DMARC record to their sending domain.
105             ["421", "4.7.40", "to add a dmarc record to "],
106             ["550", "5.7.40", "to add a dmarc record to "],
107             ],
108             'badreputation' => [
109             # - 421 4.7.0 This message is suspicious due to the very low reputation of the sending
110             # IP address/domain. To protect our users from spam, mail sent from your IP address
111             # has been temporarily rate limited. For more information, go to Why has Gmail blocked
112             # my messages?. https://support.google.com/mail/answer/188131
113             ['421', '4.7.0', 'very low reputation of the sending ip address'],
114             ['421', '4.7.0', 'very low reputation of the sending domain'],
115              
116             # - 550 5.7.1 Our system has detected that this message is likely suspicious due to the
117             # very low reputation of the sending IP address/domain. To best protect our users
118             # from spam, the message has been blocked.
119             # Please visit https://support.google.com/mail/answer/188131 for more information.
120             ['550', '5.7.1', 'due to the very low reputation of the sending ip address'],
121             ['550', '5.7.1', 'due to the very low reputation of the sending domain'],
122             ],
123             'blocked' => [
124             # - 421 4.7.0 IP not in whitelist for RCPT domain, closing connection.
125             # For more information, go to Allowlists, denylists, and approved senders.
126             # https://support.google.com/a/answer/60752
127             ['421', '4.7.0', 'ip not in whitelist for rcpt domain'],
128              
129             # - 421 4.7.0 Try again later, closing connection. This usually indicates a Denial of
130             # Service (DoS) for the SMTP relay at the HELO stage.
131             # https://support.google.com/a/answer/3221692
132             ['421', '4.7.0', 'try again later, closing connection.'],
133              
134             # - 501 5.5.4 HELO/EHLO argument is invalid. https://support.google.com/mail/?p=helo
135             ['501', '5.5.4', 'empty helo/ehlo argument not allowed'],
136             ['501', '5.5.4', 'helo/ehlo argument is invalid'],
137              
138             # - 421 4.7.28 Gmail has detected an unusual rate of mail
139             # (originating from)
140             # - your IP address 192.0.2.25
141             # - your IP Netblock 192.0.2.0/24 (?)
142             # - your DKIM domain example.org
143             # - your SPF domain example.org
144             # (containing one of your URL domains)
145             #
146             # To protect our users from spam, mail has been temporarily rate limited. To review
147             # our bulk email senders guidelines, go to Email sender guidelines.
148             # https://support.google.com/mail/?p=UnsolicitedRateLimitError
149             ['421', '4.7.0', 'an unusual rate of unsolicited mail'],
150             ['421', '4.7.28', 'an unusual rate of mail'],
151              
152             # - 550 5.7.1 Our system has detected an unusual rate of unsolicited mail originating
153             # from your IP address. To protect our users from spam, mail sent from your IP ad-
154             # dress has been blocked. Review https://support.google.com/mail/answer/81126
155             #
156             # - 550 5.7.28 There is an unusual rate of unsolicited mail originating from your IP
157             # address. To protect our users from spam, mail sent from your IP address has been
158             # blocked. To review our bulk email senders guidelines, go to Email sender guidelines.
159             ['550', '5.7.1', 'an unusual rate of unsolicited mail'],
160             ['550', '5.7.28', 'an unusual rate of unsolicited mail'],
161             ],
162             'contenterror' => [
163             # - 552 5.7.0 Our system detected an illegal attachment on your message. Please visit
164             # http://mail.google.com/support/bin/answer.py?answer=6590 to review our attachment
165             # guidelines.
166             ['552', '5.7.0', 'illegal attachment on your message'],
167              
168             # - 552 5.7.0 This message was blocked because its content presents a potential securi-
169             # ty issue. Please visit https://support.google.com/mail/?p=BlockedMessage to review
170             # our message content and attachment content guidelines.
171             ['552', '5.7.0', 'blocked because its content presents a potential security issue'],
172             ],
173             'emailtoolarge' => [
174             # - 552 5.2.3 Your message exceeded Google's message size limits. For more information,
175             # visit https://support.google.com/mail/answer/6584
176             ['552', '5.2.3', "exceeded google's message size limits"],
177              
178             # - 552 5.3.4 The number of attachments (num-attachments) exceeds Google's limit of
179             # limit attachments. To view our attachment size guidelines, go to Gmail receiving
180             # limits in Google Workspace. https://support.google.com/a/answer/1366776
181             #
182             # - 552 5.3.4 The size of the
header value (size bytes) exceeds Google's
183             # limit of limit bytes per individual header size. To view our header size guidelines,
184             # go to Gmail message header limits https://support.google.com/a?p=header-limits
185             #
186             # - 552 5.3.4 Your message exceeded Google's message size limits. To view our message
187             # size guidelines, go to Send attachments with your Gmail message.
188             # - https://support.google.com/mail/?p=MaxSizeError
189             #
190             # - 552 5.3.4 The size of your message (size bytes) exceeded Google's message size
191             # limits of limit bytes. To view our message size guidelines, go to Gmail receiving
192             # limits in Google Workspace.
193             # - https://support.google.com/mail/?p=MaxSizeError
194             ['552', '5.3.4', "exceeds google's message size limit of"],
195             ['552', '5.3.4', "exceeded google's message size limits"],
196             ['552', '5.3.4', "exceeds google's limit of limit attachments."],
197             ['552', '5.3.4', "your message exceeded google's message header size limits"],
198             ['552', '5.3.4', 'bytes per individual header size'],
199             ['552', '5.3.4', "exceeds google's header name limit of"],
200             ['552', '5.3.4', "exceeds google's message header size limit"]
201             ],
202             'expired' => [
203             # - 421 4.7.0 Connection expired, try reconnecting. For more information, go to About
204             # SMTP error messages. https://support.google.com/a/answer/3221692
205             ['421', '4.7.0', 'connection expired'],
206              
207             # - 451 4.4.2 Timeout - closing connection. For more information, go to About SMTP
208             # error messages. https://support.google.com/a/answer/3221692
209             ['451', '4.4.2', 'timeout - closing connection'],
210             ],
211             "failedstarttls" => [
212             # - 530 5.7.0 Must issue a STARTTLS command first. For more information, go to About
213             # SMTP error messages and review RFC 3207 specifications.
214             ['530', '5.7.0', 'must issue a starttls command first'],
215             ['454', '5.5.1', 'starttls may not be repeated'],
216              
217             # - 421 4.7.0 TLS required for RCPT domain, closing connection. For more information,
218             # go to Email encryption in transit. https://support.google.com/mail/answer/6330403
219             ['421', '4.7.0', 'tls required for rcpt domain'],
220              
221             # - 421 4.7.29 Your email has been rate limited because this message wasn't sent over a
222             # TLS connection. Gmail requires all bulk email senders to use TLS/SSL for SMTP conn-
223             # ections.
224             ['421', '4.7.29', 'senders to use tls/ssl for smtp'],
225             ['550', '5.7.29', 'senders to use tls/ssl for smtp'],
226             ],
227             'mailboxfull' => [
228             # - 452 4.2.2 The recipient's inbox is out of storage space.
229             # Please direct the recipient to https://support.google.com/mail/?p=OverQuotaTemp
230             # - Please direct the recipient to https://support.google.com/mail/?p=OverQuotaPerm
231             ['452', '4.2.2', 'inbox is out of storage space'],
232             ['552', '5.2.2', 'inbox is out of storage space and inactive'],
233              
234             # - 452 4.2.2 The email account that you tried to reach is over quota. Please direct
235             # the recipient to Clear Google Drive space & increase storage.
236             ['452', '4.2.2', 'is over quota'],
237             ['552', '5.2.2', 'is over quota'],
238             ['550', '5.7.1', 'email quota exceeded'],
239             ],
240             'networkerror' => [
241             # - 554 5.4.6 Message exceeded 50 hops, this may indicate a mail loop.
242             # For more information, go to Gmail Help. https://support.google.com/mail/?p=MailLoop
243             ['554', '5.4.6', 'message exceeded 50 hops'],
244             ['554', '5.6.0', 'message exceeded 50 hops'],
245             ],
246             'norelaying' => [
247             # - 550 5.7.0 Mail relay denied . Invalid credentials for relay for one of
248             # the domains in: (as obtained from HELO and MAIL FROM). Email is being
249             # sent from a domain or IP address which isn't registered in your Workspace account.
250             # Please login to your Workspace account and verify that your sending device IP
251             # address has been registered within the Workspace SMTP Relay Settings. For more
252             # information, go to SMTP relay service error messages.
253             # - https://support.google.com/a/answer/6140680#maildenied
254             ['550', '5.7.0', 'mail relay denied'],
255              
256             # - 550 5.7.1 Invalid credentials for relay . The IP address you've
257             # registered in your Workspace SMTP Relay service doesn't match the domain of the
258             # account this email is being sent from. If you are trying to relay mail from a
259             # domain that isn't registered under your Workspace account or has empty
260             # envelope-from:, you must configure your mail server either to use SMTP AUTH to
261             # identify the sending domain or to present one of your domain names in the HELO or
262             # EHLO command. For more information, go to SMTP relay service error messages.
263             # - https://support.google.com/a/answer/6140680#invalidcred
264             ['550', '5.7.1', 'invalid credentials for relay'],
265              
266             # - 550 7.7.1 The IP you're using to send mail is not authorized to send email directly
267             # to our servers. Use the SMTP relay at your service provider instead. For more
268             # information, go to 'The IP you're using to send email is not authorized...'.
269             # - https://support.google.com/mail/?p=NotAuthorizedError
270             ['550', '5.7.1', 'is not authorized to send email directly to our servers'],
271             ],
272             'notcompliantrfc' => [
273             # - 550 5.7.1 Messages missing a valid address in the From: header, or having no From:
274             # header, are not accepted. For more information, go to Email sender guidelines and
275             # review RFC 5322 specifications.
276             # - https://support.google.com/mail/?p=RfcMessageNonCompliant
277             ['550', '5.7.1', 'missing a valid address in the from: header'],
278             ['550', '5.7.1', 'multiple addresses in from: header are not accepted'],
279              
280             # - 550 5.7.1 This message is not RFC 5322 compliant because it has duplicate headers.
281             # To reduce the amount of spam sent to Gmail, this message has been blocked. For more
282             # information, go to Email sender guidelines and review RFC 5322 specifications.
283             # - https://support.google.com/mail/?p=RfcMessageNonCompliant
284             ['550', '5.7.1', 'is not rfc 5322 compliant'],
285              
286             # - 550 5.7.1 Messages missing a valid Message-ID: header are not accepted. For more
287             # information, go to Email sender guidelines and review RFC 5322 specifications.
288             # - https://support.google.com/mail/?p=RfcMessageNonCompliant
289             ['550', '5.7.1', 'missing a valid message-id: header'],
290              
291             # - 550 5.7.1 The message contains a unicode character in a disallowed header.
292             # To review our message and header content guidelines, go to File types blocked in
293             # Gmail. https://support.google.com/mail/?p=BlockedMessage
294             ['550', '5.7.1', 'contains a unicode character in a disallowed header'],
295              
296             # - 550 5.7.1 Encoded-word syntax is not permitted in message header header-name. To
297             # reduce the amount of spam sent to Gmail, this message has been blocked. For more
298             # information, go to Email sender guidelines and review RFC 5322 specifications.
299             # - https://support.google.com/mail/?p=RfcMessageNonCompliant
300             ['550', '5.7.1', 'encoded-word syntax is not permitted'],
301              
302             # - 553 5.1.7 The sender address address is not a valid RFC 5321 address. For more
303             # information, go to About SMTP error messages and review RFC 5321 specifications.
304             # - https://support.google.com/a/answer/3221692
305             ['553', '5.1.7', 'is not a valid rfc 5321 address'],
306              
307             # - 554 5.6.0 Mail message is malformed. Not accepted. For more information, go to
308             # Email sender guidelines and review RFC 5322 specifications.
309             # - https://support.google.com/mail/?p=RfcMessageNonCompliant
310             ['554', '5.6.0', 'mail message is malformed'],
311             ],
312             'policyviolation' => [
313             # - 550 5.7.1 The user or domain that you are sending to (or from) has a policy that
314             # prohibited the mail that you sent. Please contact your domain administrator for
315             # further details.
316             # For more information, visit https://support.google.com/a/answer/172179
317             ['550', '5.7.1', 'you are sending to (or from) has a policy that prohibited'],
318             ],
319             'ratelimited' => [
320             # - 450 4.2.1 The user you are trying to contact is receiving mail too quickly. Please
321             # resend your message at a later time. If the user is able to receive mail at that
322             # time, your message will be delivered.
323             # For more information, visit https://support.google.com/mail/answer/22839
324             #
325             # - 450 4.2.1 Peak SMTP relay limit exceeded for customer. This is a temporary error.
326             # For more information on SMTP relay limits, please contact your administrator or
327             # visit https://support.google.com/a/answer/6140680
328             ['450', '4.2.1', 'is receiving mail too quickly'],
329             ['450', '4.2.1', 'peak smtp relay limit exceeded for customer'],
330              
331             # - 450 4.2.1 The user you are trying to contact is receiving mail at a rate that pre-
332             # vents additional messages from being delivered. Please resend your message at a
333             # later time. If the user is able to receive mail at that time, your message will be
334             # delivered. For more information, visit https://support.google.com/mail/answer/6592
335             # - https://support.google.com/mail/?p=ReceivingRatePerm
336             ['450', '4.2.1', 'rate that prevents additional messages from being delivered'],
337             ['550', '5.2.1', 'rate that prevents additional messages from being delivered'],
338              
339             # - 452 4.5.3 Your message has too many recipients. For more information regarding
340             # Google's sending limits, visit https://support.google.com/mail/answer/6592
341             # https://support.google.com/mail/?p=TooManyRecipientsError
342             ['452', '4.5.3', 'your message has too many recipients'],
343             ['550', '5.5.3', 'too many recipients for this sender'],
344              
345             # - 550 5.4.5 Daily SMTP relay limit exceeded for user. For more information on SMTP
346             # relay sending limits please contact your administrator or visit SMTP relay service
347             # error messages.
348             # https://support.google.com/a/answer/6140680
349             # - https://support.google.com/a/answer/166852
350             ['550', '5.4.5', 'daily sending quota exceeded'],
351             ['550', '5.4.5', 'daily user sending limit exceeded'],
352             ['550', '5.4.5', 'daily smtp relay limit exceeded for'],
353             ['550', '5.7.1', 'daily smtp relay limit exceeded for'],
354             ['550', '5.7.1', 'daily smtp relay sending limit exceeded for'],
355             ['550', '5.7.1', 'this mail has been rate limited'],
356              
357             # - 421 4.7.28 Gmail has detected this message exceeded its quota for sending messages
358             # with the same Message-ID:. To best protect our users, the message has been tempo-
359             # rarily rejected. For more information, go to Why has Gmail blocked my messages?.
360             # https://support.google.com/mail/answer/188131
361             ['421', '4.7.28', 'sending messages with the same message-id:'],
362             ],
363             'rejected' => [
364             # - 550 5.7.0, Mail Sending denied. This error occurs if the sender account is disabled
365             # or not registered within your Google Workspace domain.
366             # - https://support.google.com/a/answer/6140680#maildenied
367             ['550', '5.7.0', 'mail sending denied'],
368             ['550', '5.7.1', 'unauthenticated email is not accepted'],
369             ],
370             'requireptr' => [
371             # - 421 4.7.0 The IP address sending this message does not have a PTR record, or the
372             # corresponding forward DNS entry does not point to the sending IP. To protect our
373             # users from spam, mail sent from your IP address has been temporarily rate limited.
374             # For more information, go to Email sender guidelines.
375             ['421', '4.7.0', 'does not have a ptr record'],
376              
377             # - 421 4.7.23 The sending IP address for this message doesn't have a PTR record, or
378             # the PTR record's forward DNS entry doesn't match the sending IP address. To protect
379             # users from spam, your email has been temporarily rate limited.
380             ['421', '4.7.23', ' have a ptr record, or the ptr record'],
381              
382             # - 550 5.7.1 This message does not meet IPv6 sending guidelines regarding PTR records
383             # and authentication. For more information, go to Email sender guidelines.
384             # https://support.google.com/mail/?p=IPv6AuthError
385             #
386             # - 550 5.7.25 The IP address sending this message does not have a PTR record setup, or
387             # the corresponding forward DNS entry does not point to the sending IP. As a policy,
388             # Gmail does not accept messages from IPs with missing PTR records.
389             # For more information, go to Email sender guidelines.
390             # - https://support.google.com/mail/answer/81126#ip-practices
391             #
392             # - 550 5.7.25 The sending IP does not match the IP address of the hostname specified
393             # in the pointer (PTR) record. For more information, go to Email sender guidelines.
394             # - https://support.google.com/mail/answer/81126#ip-practices
395             ['550', '5.7.1', 'does not meet ipv6 sending guidelines regarding ptr records and authentication'],
396             ['550', '5.7.25', 'does not have a ptr record'],
397             ['550', '5.7.25', 'does not match the ip address of the hostname'],
398             ],
399             'securityerror' => [
400             # - 454 4.7.0 Too many login attempts, please try again later. For more information, go
401             # to Add Gmail to another email client. https://support.google.com/mail/answer/7126229
402             ['454', '4.7.0', 'too many login attempts'],
403              
404             # - 503 5.7.0 No identity changes permitted. For more information, go to About SMTP
405             # error messages.
406             ['501', '5.5.2', 'cannot decode response'], # 2FA related error, maybe.
407             ['503', '5.7.0', 'no identity changes permitted'],
408              
409             # - 530 5.5.1 Authentication Required. For more information, visit
410             # https://support.google.com/accounts/troubleshooter/2402620
411             # - https://support.google.com/mail/?p=WantAuthError
412             ['530', '5.5.1', 'authentication required.'],
413             ['530', '5.7.0', 'authentication required.'],
414              
415             # - 535 5.7.1 Application-specific password required.
416             # For more information, visit https://support.google.com/accounts/answer/185833
417             ['535', '5.7.1', 'application-specific password required'],
418             ['535', '5.7.90', 'application-specific password required'],
419              
420             # - 535 5.7.1 Please log in with your web browser and then try again. For more infor-
421             # mation, visit https://support.google.com/mail/bin/accounts/answer/78754
422             ['535', '5.7.1', 'please log in with your web browser'],
423             ['534', '5.7.90', 'please log in with your web browser'],
424             ['534', '5.7.14', 'please log in through your web browser'],
425              
426             # - 535 5.7.1 Username and Password not accepted. For more information, visit
427             # https://support.google.com/accounts/troubleshooter/2402620
428             ['535', '5.7.1', 'username and password not accepted'],
429             ['535', '5.7.80', 'username and password not accepted'],
430             ],
431             'spamdetected' => [
432             # - 421 4.7.0 This message is suspicious due to the nature of the content or the links
433             # within. To best protect our users from spam, the message has been blocked. For more
434             # information, go to Why has Gmail blocked my messages?.
435             # https://support.google.com/mail/answer/188131
436             ['421', '4.7.0', 'due to the nature of the content or the links within'],
437              
438             # - 550 5.7.1 Our system has detected that this message is likely unsolicited mail. To
439             # reduce the amount of spam sent to Gmail, this message has been blocked.
440             # For more information, visit https://support.google.com/mail/answer/188131
441             # - https://support.google.com/mail/?p=UnsolicitedMessageError
442             ['550', '5.7.1', 'likely unsolicited mail'],
443             ],
444             'suspend' => [
445             # - 550 5.2.1 The email account that you tried to reach is inactive.
446             # For more information, go to https://support.google.com/mail/?p=DisabledUser
447             ['550', '5.2.1', 'account that you tried to reach is disabled'],
448             ['550', '5.2.1', 'account that you tried to reach is inactive'],
449             ],
450             'syntaxerror' => [
451             # - 523 5.7.10 SMTP protocol violation, no commands allowed to pipeline after STARTTLS.
452             # For more information, go to About SMTP error messages and review RFC 3207
453             # specifications.
454             ['451', '4.5.0', 'smtp protocol violation'],
455             ['454', '4.5.0', 'smtp protocol violation'],
456             ['525', '5.7.10', 'smtp protocol violation'],
457             ['535', '5.5.4', 'optional argument not permitted'],
458              
459             # - 501 5.5.2 Syntax error, cannot decode response. For more information, go to About
460             # SMTP error messages.
461             # - https://support.google.com/a/answer/3221692
462             # - 501 5.7.11 Syntax error (no parameters allowed). For more information, go to About
463             # SMTP error messages and review RFC 3207 specifications.
464             ['501', '5.7.11', 'syntax error'],
465             ['501', '5.5.2', 'syntax error'],
466             ['555', '5.5.2', 'syntax error'],
467              
468             # - 503 5.5.1 Bad sequence of commands. For more information, go to About SMTP error
469             # messages and review RFC 5321 specifications.
470             # - https://support.google.com/mail/?p=helo
471             #
472             # - 503 5.5.1 No DATA after BDAT. A mail transaction protocol command was issued out of
473             # sequence. For more information, go to About SMTP error messages and review RFC 3030
474             # specifications.
475             # - https://support.google.com/a/answer/3221692
476             ['502', '5.5.1', 'too many unrecognized commands, goodbye'],
477             ['502', '5.5.1', 'unimplemented command'],
478             ['502', '5.5.1', 'unrecognized command'],
479             ['503', '5.5.1', 'bad sequence of commands'],
480             ['503', '5.5.1', 'ehlo/helo first'],
481             ['503', '5.5.1', 'mail first'],
482             ['503', '5.5.1', 'rcpt first'],
483             ['503', '5.5.1', 'no data after bdat'],
484             ['504', '5.7.40', 'unrecognized authentication type'],
485             ['504', '5.7.40', 'xoauth is no longer supported'],
486             ['554', '5.7.0', 'too many unauthenticated commands'],
487             ],
488             'systemerror' => [
489             # About SMTP error messages, https://support.google.com/a/answer/3221692
490             ['421', '4.3.0', 'temporary system problem'],
491             ['421', '4.7.0', 'temporary system problem'],
492             ['421', '4.4.5', 'server busy'],
493              
494             # - 451 4.3.0 Multiple destination domains per transaction is unsupported. Please try
495             # again. For more information, go to About SMTP error messages and review RFC 5321
496             # specifications. https://support.google.com/a/answer/3221692
497             ['451', '4.3.0', 'multiple destination domains per transaction is unsupported'],
498             ['451', '4.3.0', 'mail server has temporarily rejected this message'],
499             ['451', '4.3.0', 'mail server temporarily rejected message'],
500              
501             # - 452 4.5.3 Domain policy size per transaction exceeded, please try this recipient in
502             # a separate transaction. This message means the email policy size (size of policies,
503             # number of policies, or both) for the recipient domain has been exceeded.
504             # https://support.google.com/a/answer/7282433
505             ['452', '4.5.3', 'domain policy size per transaction exceeded'],
506              
507             # - 454 4.7.0 Cannot authenticate due to a temporary system problem. Try again later.
508             # For more information, go to About SMTP error messages.
509             # https://support.google.com/a/answer/3221692
510             ['454', '4.7.0', 'cannot authenticate due to temporary system problem'],
511             ],
512             'userunknown' => [
513             # - 550 5.1.1 The email account that you tried to reach does not exist. Please try dou-
514             # ble-checking the recipient's email address for typos or unnecessary spaces.
515             # For more information, visit https://support.google.com/mail/answer/6596
516             # - https://support.google.com/mail/?p=NoSuchUser
517             ['550', '5.1.1', 'the email account that you tried to reach does not exist'],
518              
519             # - 553 5.1.2 We weren't able to find the recipient domain. Please check for any spell-
520             # ing errors, and make sure you didn't enter any spaces, periods, or other punctua-
521             # tion after the recipient's email address.
522             # - https://support.google.com/mail/?p=BadRcptDomain
523             ['553', '5.1.2', "we weren't able to find the recipient domain"],
524              
525             # - 553 5.1.3 The recipient address
is not a valid RFC 5321 address. For more
526             # information, go to About SMTP error messages and review RFC 5321 specifications.
527             # - https://support.google.com/a/answer/3221692
528             ['553', '5.1.3', 'is not a valid rfc 5321 address'],
529             ],
530             };
531              
532 130         485 my $statuscode = substr($argvs->{'deliverystatus'}, 2); # 5.7.1 => 7.1
533 130         408 my $esmtpreply = substr($argvs->{'replycode'}, 1, 2); # 421 => 21
534 130         473 my $issuedcode = lc $argvs->{'diagnosticcode'};
535 130         247 my $reasontext = '';
536              
537 130         1133 REASON: for my $e ( keys %$messagesof ) {
538             # Each key is a reason name
539 1354         2475 for my $f ( $messagesof->{ $e }->@* ) {
540             # Try to match an SMTP reply code, a D.S.N., and an error message
541 7819 100       18158 next unless index($issuedcode, $f->[2]) > -1;
542 170 100       693 next unless index($f->[0], $esmtpreply) > 0;
543 125 100       541 next unless index($f->[1], $statuscode) > 1;
544 115         239 $reasontext = $e;
545 115         268 last REASON;
546             }
547             }
548 130         896 return $reasontext;
549             }
550              
551             1;
552             __END__