Open tobiascapin opened 3 years ago
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
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...
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.
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...
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
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)
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?