Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Component/Mailer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.1
---

* Allow manually stop() of `SmtpTransport`

6.0
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ public function testWriteEncodedRecipientAndSenderAddresses()
$this->assertContains("RCPT TO:<[email protected]>\r\n", $stream->getCommands());
$this->assertContains("RCPT TO:<[email protected]>\r\n", $stream->getCommands());
}

public function testStop()
{
$stream = new DummyStream();
$envelope = new Envelope(new Address('[email protected]'), [new Address('[email protected]')]);

$transport = new SmtpTransport($stream);
$transport->send(new RawMessage('Message 1'), $envelope);
$this->assertFalse($stream->isClosed());

$transport->stop();
$this->assertTrue($stream->isClosed());
}
}

class DummyStream extends AbstractStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,14 @@ private function start(): void
$this->getLogger()->debug(sprintf('Email transport "%s" started', __CLASS__));
}

private function stop(): void
/**
* Manually disconnect from the SMTP server.
*
* In most cases this is not necessary since the disconnect happens automatically on termination.
* In cases of long-running scripts, this might however make sense to avoid keeping an open
* connection to the SMTP server in between sending emails.
*/
public function stop(): void
{
if (!$this->started) {
return;
Expand Down