I'm trying to determine the availability of a SMTP server or a valid authentication of a SMTP server while sending mail by Zend\Mail\Transport\Smtp.
I can detect that mail is not sent due to server unavailable or server settings wrong or server authentication fail. All code running well and exception is caught properly. But when my script is at end position i.e. when PHP try to destroy connection variable automatically Zend is try to disconnect server and try to destroy that instance. That time server is not UP cause I know the server settings is wrong. While destroying that instance it arise
"Fatal error: Uncaught exception 'Zend\Mail\Protocol\Exception\RuntimeException' with message 'Could not read from XXX.XXX.XXX.XXX'"
I cannot grab that error in any way! I tried set error handler, set exception handler but no luck. Cause its return while destructing. And PHP control that destruction process...
I try by putting try ... catch block in __destroy
method but it arise more error.
Any suggestion?