zytzagoo / smtp-validate-email

A PHP library for performing email addresses validation via SMTP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

421 4.7.1 Intrusion prevention active

vladan-me opened this issue · comments

Hi,

First, thanks for great script. I'd like to see if this issue can be somehow resolved.
After sending bulk 100+ request I've got this error:

SMTP_Validate_Email_Exception_Unexpected_Response: 421 4.7.1 Intrusion prevention active for [my ip address][R] in SMTP_Validate_Email->expect() (line 658

If there's no good way to solve it, can it just be ignored and moved on?
Problem is that it breaks script completely and don't want to continue...

Well, that depends on several things:

  • your definition of (re)solving
  • the details of the command that was sent (and the full response) at the specific moment you got that error/response (or, in other terms, at which point the server finally decided to block you -- they usually issue warnings first, which allows you to back off for a bit and try again later)

If your only goal is to hide any potential errors/exceptions that occur during validation you could try just wrapping your validate() call within a try/catch block. How useful the entire validation then becomes is up to you.

If you'd like to dig deeper and find out exactly what's happening (and at which point), you should turn on debugging (set $debug = true) and see the exact command/response flow.

After you know the details, you can maybe try modifying the expected responses of the commands being sent to the server (if/when the server responds to us with something "expected", we don't throw).

For example, if we'd like the noop command/method to treat a generic 421 response as expected, we'd change it from:

    $this->send('NOOP');
    $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['noop']);

to:

    $this->send('NOOP');
    $this->expect(array(self::SMTP_GENERIC_SUCCESS, self::SMTP_SERVICE_UNAVAILABLE), $this->command_timeouts['noop']);

Again, how useful that becomes... I'm not sure. I'd consider it useless, since I'm not really getting an answer to that initial question of "does this e-mail address really exist?".

Finally, if your definition of (re)solving is more along the lines of "I'd like to do 'this-one-thing' and be allowed to query the same server again as I did previously" -- I'm afraid I don't have an easy out-of-the-box solution for you. The server just doesn't like you any more + doing bulk validation requires proper infrastructure. Getting that infrastructure built and maintained is probably going to cost you more than just paying for any of the bazillion "bulk email validation" products/services that exist today.

Thank you for detailed answer.
Yes, you are completely right.
I've run it in debug mode but it just happens all out of sudden, I just get disconnected after few checks. I thought that I get this response from mail server that I am sending mail to so I can continue asking other ones but this is actually from my own mailing server (which is Mandrill btw). After that is literally useless to continue doing anything. Guess I'll have to consider using external service for this since, as you said, infrastructure and maintenance can be quite expensive.

Thanks again