zytzagoo / smtp-validate-email

A PHP library for performing email addresses validation via SMTP
GNU General Public License v3.0
437 stars 155 forks source link

Timeout doesn't work #39

Open jgcabral opened 6 years ago

jgcabral commented 6 years ago

I'm extending class and inside function constructor i set timeout = 250(ms) but i when execute the script delay more time. Often it happen with email address hotmail.

zytzagoo commented 6 years ago

Can you show where/how exactly you're doing that? This class's constructor does not accept timeout as an option by default, so hard to tell what's going on in some custom code of yours...

Are you using setConnectTimeout()? Are we talking about connect timeout at all, or some other timeout? Unit tests show that setting/getting the connect timeout works as expected. Functional test too.

jgcabral commented 6 years ago

The code is the following. $validator = new EmailValidator($email, $sender); $validator->setConnectTimeout(0.25); but when i enter any address hotmail's, delay a lot of time.

zytzagoo commented 6 years ago

Connect timeout must (currently) be specified as integer seconds, not float (https://secure.php.net/stream_set_timeout is used), so that might be one of the reasons why its "not working", but we'll have to define what not working really means in this context...

Do you have some debug logs/timestamps which show that the delay is actually happening at the connect phase?

Could it be that Hotmail is throttling you due to bad/spammy behaviour and/or bad/spammy ip reputation/history?

zytzagoo commented 6 years ago

Does setting the connect timeout to 1 (second) help as a workaround? Or does that also have no effect at all?

jgcabral commented 6 years ago

You're right, i think hotmail's servers are generating delay. I have tried setting 1 second but no success. I need to set 250 ms for any email server. I have no logs to show you,

zytzagoo commented 6 years ago

Feature request 1: Maybe being able to set sub-second connectTimeout, but even if implemented, it does not help with server-generated delays/throttling.

Feature request 2: Detecting delays/throttling (and maybe dropping the connection in that case, and it being somewhat configurable)

These are not something I planned on adding myself (no need for it), however, if someone contributes the code and tests for it, I'll more than gladly review and merge.

jgcabral commented 6 years ago

Ok, thanks anyway.