zendframework/zf2 — pull request #4690 by mwillbanks (2013-06-19 21:27:56+00:00)
Title: Zend\Mail\Protocol\Smtp does not reset protected $auth after disconnect

I use an offline worker process to process sending out of emails, as such keeping a connection open too long can cause issues with timeouts. Therefore I have my worker disconnect when it hits an internal timeout. Example:

```php
public function wait()
{
if ($this->isConnected) {
$this->log('disconnecting');
$this->mail->disconnect();
$this->isConnected = false;
}

return parent::wait();
}
```

When it re-connects and attempts to send out an email, it fatally errors: Fatal error: Already authenticated for this session in /var/www/vendor/zendframework/zendframework/library/Zend/Mail/Protocol/Smtp.php on line 368

This is due to when the disconnect portion of the mail code is hit, it does not actually reset the $auth flag. As you can see from a greg command there is no place in where the flag is set back to false and is always true if you keep the same instance around and reuse it.

This change does 2 things:
1. The SmtpProtocolSpy test asset has to have methods to set and get the protected members ($auth and $sess).
We need both of these for simple reasons; $auth because we need to manually set it since we actually never really call any of the methods and secondly $sess because otherwise the ->quit() method would never actually make it into the block.

2. Changes the quit() method to contain $this->auth = false (since this is indeed where most of the cleanup methods are for disconnect().