smtp-validate-email icon indicating copy to clipboard operation
smtp-validate-email copied to clipboard

All address at the same domain becomes invalid if the server responds with 421 4.7.0 Error: too many errors

Open orionstar opened this issue 4 years ago • 5 comments

I'm doing batch validations for my mail lists (ten thousends addresses) . A few email provider gives me error like below with varying account status (inactive, deleted, blocked etc): 550 5.1.1 <[email protected]>: Recipient address rejected: u'SMTP service is disabled for this account. AccountId: 12345678. Reason: The account is INACTIVE' Unexpected response to RCPT TO: 550 5.1.1 <[email protected]>: Recipient address rejected: u'SMTP service is disabled for this account. AccountId: 12345678. Reason: The account is INACTIVE' (I've changed the mailbox name to placeholder)

After errors like this all address at the same domain becomes invalid even if I got back 250 2.1.5 Ok for the most of them.

This problem only occurs if I'm validating large batches. If I only validate 50 or so the issue doesn't occur.

orionstar avatar Dec 18 '20 12:12 orionstar

Ok, so what does the code on php side look like for that? Especially the part which is (supposedly?) using this library?

zytzagoo avatar Dec 18 '20 16:12 zytzagoo

I'm basically using the sample code without customization: $validator = new SmtpEmailValidator($emails, $sender); $results = $validator->validate();

The $emails array contains 20 to 50 thousands of addresses when I'm facing the issue, the $sender is my company's email address. When I started to debug then I enabled the debug property by setting it true.

orionstar avatar Dec 18 '20 16:12 orionstar

Could be related to "catch-all" and/or no_comm_is_valid settings/handling ? (see catchall_is_valid property: https://github.com/zytzagoo/smtp-validate-email/blob/master/src/Validator.php#L41) and the logic inside performSmtpDance() (https://github.com/zytzagoo/smtp-validate-email/blob/master/src/Validator.php#L391)

Could you maybe produce a reduced example that reproduces the issue reliably? (amount of emails should not matter as such, same bug should be reproducible with 2-3 recipients on the same domain)

zytzagoo avatar Dec 18 '20 16:12 zytzagoo

A bit off topic. How many emails should we validate at the same time?

b4nghh avatar Dec 20 '20 17:12 b4nghh

Now I had time to dig deeper. The last error is always 421 4.7.0 mx.onbox.hu Error: too many errors. If I have 20 failed address then this response triggered by some of the hosts and after that Validator.php::802 expect() throws UnexpectedResponseException beacuse of the error code (421) then its catched in line 360 and it sets all address as invalid inspite of previous successfull checks. I assume the expect() method should be refactored by throwing a new ReconnectNeededException if it encounters with 421 4.7.0 then it should be catched in the address foreach (line 342) and reconnect if it happens.

Example set: $addresses = [ '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', ];

If you delete one of the made up mail address then the validation will work correctly.

In my case I limited my batches to max 20 addresses at these providers as a hotfix.

Thank you for your assistance. Merry Xmas! ;)

orionstar avatar Dec 24 '20 23:12 orionstar