diff --git a/src/Protocol/Smtp.php b/src/Protocol/Smtp.php index 941ead59..6e31b376 100644 --- a/src/Protocol/Smtp.php +++ b/src/Protocol/Smtp.php @@ -348,6 +348,7 @@ public function vrfy($user) public function quit() { if ($this->sess) { + $this->auth = false; $this->_send('QUIT'); $this->_expect(221, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 $this->_stopSession(); diff --git a/test/Protocol/SmtpTest.php b/test/Protocol/SmtpTest.php index 1784996f..96639bf0 100644 --- a/test/Protocol/SmtpTest.php +++ b/test/Protocol/SmtpTest.php @@ -66,4 +66,14 @@ public function testDisconnectCallsQuit() $this->connection->disconnect(); $this->assertTrue($this->connection->calledQuit); } + + public function testDisconnectResetsAuthFlag() + { + $this->connection->connect(); + $this->connection->setSessionStatus(true); + $this->connection->setAuth(true); + $this->assertTrue($this->connection->getAuth()); + $this->connection->disconnect(); + $this->assertFalse($this->connection->getAuth()); + } } diff --git a/test/TestAsset/SmtpProtocolSpy.php b/test/TestAsset/SmtpProtocolSpy.php index 86877e62..e37bccaa 100644 --- a/test/TestAsset/SmtpProtocolSpy.php +++ b/test/TestAsset/SmtpProtocolSpy.php @@ -29,6 +29,7 @@ class SmtpProtocolSpy extends Smtp public function connect() { $this->connect = true; + return true; } @@ -107,4 +108,50 @@ public function getRecipients() { return $this->rcptTest; } + + /** + * Get Auth Status + * + * @return bool + */ + public function getAuth() + { + return $this->auth; + } + + /** + * Set Auth Status + * + * @param bool $status + * @return self + */ + public function setAuth($status) + { + $this->auth = (bool) $status; + + return $this; + } + + /** + * Get Session Status + * + * @return bool + */ + public function getSessionStatus() + { + return $this->sess; + } + + /** + * Set Session Status + * + * @param bool $status + * @return self + */ + public function setSessionStatus($status) + { + $this->sess = (bool) $status; + + return $this; + } }