Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recv: 550 IP blacklisted by Spamhaus #70

Open
tobiascapin opened this issue May 17, 2021 · 5 comments
Open

recv: 550 IP blacklisted by Spamhaus #70

tobiascapin opened this issue May 17, 2021 · 5 comments

Comments

@tobiascapin
Copy link

tobiascapin commented May 17, 2021

I'm receiving a 550 error from SMTP due to spamhaus blacklist, this is not really an invalid mail error beause the email address was not given yet but I received a 550 error! This error is thrown just after the connection.
Is it possible somehow ignore this errors?

[2021-05-17T15:53:02.318087+0000] Connecting to smtp-in.libero.it:25


[2021-05-17T15:53:02.359458+0000] Connected to smtp-in.libero.it:25 successfully


[2021-05-17T15:53:02.360149+0000] <<<recv: 550 smtp-26.iol.local smtp-26.iol.local IP blacklisted by Spamhaus, https://www.spamhaus.org/query/ip/79.50.186.118  [smtp-26.iol.local; LIB_101]


[2021-05-17T15:53:02.374261+0000] Unexpected response after connecting: 550 smtp-26.iol.local smtp-26.iol.local IP blacklisted by Spamhaus, https://www.spamhaus.org/query/ip/79.50.186.118  [smtp-26.iol.local; LIB_101]


[2021-05-17T15:53:02.374288+0000] Closing socket to smtp-in.libero.it:25
@zytzagoo
Copy link
Owner

zytzagoo commented May 18, 2021

Depends on what you mean by "ignore"...

There is an option no_comm_is_valid which controls whether not being able to talk to a server "means" email is valid or not:
https://github.com/zytzagoo/smtp-validate-email/blob/master/src/Validator.php#L401

Sample test:

public function testNoCommIsValidWithLocalSmtpRejectingOurSender()

What's your no_comm_is_valid option set to?

Another solution could perhaps be to extend the Validator class on your own and overwrite/change the way performSmtpDance() method works? That way you could do whatever you think is best for your use case...

@tobiascapin
Copy link
Author

tobiascapin commented May 18, 2021

no_comm_is_valid is set to true, but it was not enought.
I have to change a bit the helo response:

    protected function attemptMailCommands($domain, array $users)
    {
        // Bail if HELO doesn't go through...
        if (!$this->helo()) {
            $this->setDomainResults($users, $domain, $this->no_comm_is_valid);
            return;
        }

Because that server fails the transaction before the MAIL FROM command.
Adding $this->setDomainResults($users, $domain, $this->no_comm_is_valid); after the helo failure it uses the no_comm_is_valid setting and force a valid response.

What do you think?
Many thanks.

@zytzagoo
Copy link
Owner

You should be able to do that in "userland", no?

Maybe something like:

<?php

namespace Whatever\You\Need;

use \SMTPValidateEmail\Validator;

class MyModifiedValidator extends Validator
{
    protected function attemptMailCommands($domain, array $users)
    {
        // Bail if HELO doesn't go through...
        if (!$this->helo()) {
            $this->setDomainResults($users, $domain, $this->no_comm_is_valid);
            return;
        }
        
        // ... (copy over rest of original attemptMailCommands() method
    }
}

And then in your existing calling code just load your custom Whatever\You\Need\MyModifiedValidator class.
You should be able to autoload custom/extra classes using composer.json easy.
So then "just" use your new custom class instead of the original Validator?

Something like:

<?php

use Whatever\You\Need\MyModifiedValidator as Validator;

// Your existing calling code here...

Did not try it myself fully, this is just a quick idea, but sounds like it could work...

@tobiascapin
Copy link
Author

Yes this is an idea, thanks.
I wrote this issue here just as suggestion to improve the compatibility, maybe this server behaviour is not so rare.
Thanks

@zytzagoo
Copy link
Owner

If you're up for creating a pull request to modify the behavior, go for it - just make sure existing tests pass (and/or modify/add them to cover the new behavior) and we can probably merge it (and release, with a version bump and a changelog entry etc, since this is technically a somewhat breaking change for existing consumers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants