Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,27 @@ protected function tearDown(): void

public function testToString()
{
$previousSendmailPath = \ini_set('sendmail_path', '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should happen in setUp().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we should use $this->iniSet()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not relevant to all tests, though.

$t = new SendmailTransport();
$this->assertEquals('smtp://sendmail', (string) $t);
}

public function testToStringNonSmtp()
{
$previousSendmailPath = \ini_set('sendmail_path', '');
$t = new SendmailTransport('/usr/sbin/sendmail -t -i');
\ini_set('sendmail_path', $previousSendmailPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should happen in tearDown().

$this->assertEquals('sendmail://default', (string) $t);
}

public function testToStringPhpConfig()
{
$previousSendmailPath = \ini_set('sendmail_path', '/usr/sbin/sendmail -t -i');
$t = new SendmailTransport();
\ini_set('sendmail_path', $previousSendmailPath);
$this->assertEquals('sendmail://default', (string) $t);
}

public function testToIsUsedWhenRecipientsAreNotSet()
{
if ('\\' === \DIRECTORY_SEPARATOR) {
Expand Down
7 changes: 5 additions & 2 deletions src/Symfony/Component/Mailer/Transport/SendmailTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
*/
class SendmailTransport extends AbstractTransport
{
private string $command = '/usr/sbin/sendmail -bs';
private const SENDMAIL_FHS_PATH = '/usr/sbin/sendmail -bs';
private string $command;
private ProcessStream $stream;
private ?SmtpTransport $transport = null;

Expand All @@ -59,6 +60,8 @@ public function __construct(string $command = null, EventDispatcherInterface $di
}

$this->command = $command;
} else {
$this->command = \ini_get('sendmail_path') ?: self::SENDMAIL_FHS_PATH;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change the default behavior: before: -bs, after -t -i on my Ubuntu.
We need another way to opt-in for reading from ini

}

$this->stream = new ProcessStream();
Expand All @@ -83,7 +86,7 @@ public function __toString(): string
return (string) $this->transport;
}

return 'smtp://sendmail';
return 'sendmail://default';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that a bugfix? I think this should go on 5.4

}

protected function doSend(SentMessage $message): void
Expand Down