Moves the timeout check to outside of the loop so that the exception is thrown when a timeout occurs. This is because fgets returns false on a timeout and doesn't enter the loop.
PHP 5.6 seems to take longer than 5.4 to send e-mails and so I encountered this bug. After changing this I get the correct Exception and my code dies (as expected). Upping the timeout makes it succeed.
Before this change the timeout exception was not thrown and an empty string was returned (and because this was the HELP command which is optional the unexpected server response exception was ignored) causing the next piece of data to be the result of the last request (in this case) which caused an unexpected server response exception again.
fgets
returnsfalse
on a timeout and doesn't enter the loop.PHP 5.6 seems to take longer than 5.4 to send e-mails and so I encountered this bug. After changing this I get the correct Exception and my code dies (as expected). Upping the timeout makes it succeed.
Before this change the timeout exception was not thrown and an empty string was returned (and because this was the HELP command which is optional the unexpected server response exception was ignored) causing the next piece of data to be the result of the last request (in this case) which caused an unexpected server response exception again.