php - ZF2 uncaught exception on concurrent emails exceeds limit with SMTP server -
zf2 throws uncaught exception when trying send multiple mail @ same time, using smtp server.
after sending 5 emails throws exception:
uncaught exception: "could not read host" zend\mail\protocol\abstractprotocol
this comes after smtp server sends error:
message submission rate client has exceeded configured limit
since thrown when destructor called not able catch in script. suggestion how catch this, in script.
there nothing zend framework 2 or other library. message mail service consuming pretty clear: you're exceeding rate limit.
anyway, have several options;
- never send lot of e-mails in single while / loop since don't have cool paid e-mail service doesn't apply rate limit account. (paid or not every service yours applies rate limits prevent abusing. normal.)
- add
try {} catch() {}
block in script , when exceed limit, stop, wait while , try again. - you may consider writing cronjob , cli script send x emails per minute.
- implementing message queue sending emails consuming queue (x emails @ time) better if need send thousands of emails.
- ask mail service provider increase limits.
- change mail service provider if rates still not enough.
Comments
Post a Comment