Skip to content

Commit

Permalink
Added test with mesage body that breaks if dot stuffing is done befor…
Browse files Browse the repository at this point in the history
…e encoding. Changed `Writer::writeFiltered` to use `stream_filter_prepend`.
  • Loading branch information
vortrixs committed Oct 2, 2024
1 parent bab7208 commit a58d7b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function writeBase64($input): void
*/
protected function writeFiltered($input, string $filter, array $options = []): void
{
$filter = stream_filter_append($this->output, $filter, STREAM_FILTER_WRITE, $options);
$filter = stream_filter_prepend($this->output, $filter, STREAM_FILTER_WRITE, $options);

$this->write($input);

Expand Down
27 changes: 27 additions & 0 deletions tests/integration/MailServiceCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Kodus\Mail\Test\Integration;

use IntegrationTester;
use Kodus\Mail\Address;
use Kodus\Mail\Message;
use Kodus\Mail\SMTP\Authenticator\NoAuthenticator;
use Kodus\Mail\SMTP\SMTPMailService;
use Kodus\Mail\Test\TestMessageFactory;
Expand Down Expand Up @@ -31,4 +33,29 @@ public function sendMail(IntegrationTester $I)
$service->send($message);
}
}

public function ensureDotStuffingHappensBeforeQuotePrintableEncode(IntegrationTester $I)
{
$text_body = <<<EOT
Test mail 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890.
More text.
EOT;

$service = new SMTPMailService(
$I->createSocketConnector(), new NoAuthenticator(), "localhost"
);

$message = new Message(
new Address("[email protected]", "Rasmus åh Schultz"),
new Address("[email protected]"),
"Hey, Rasmus! I like ÆØÅæøå!",
$text_body,
);

$message->setDate("Thu, 15 Sep 2016 17:20:54 +0200");

$message->setSender(new Address("[email protected]"));

$service->send($message);
}
}

0 comments on commit a58d7b9

Please sign in to comment.