-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Support getting sendmail path from php.ini #51749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Not all environments have sendmail installed in `/usr/sbin`. Let’s ask for the path using `ini_get`. See also symfony/swiftmailer-bundle#302
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,13 +38,24 @@ protected function tearDown(): void | |
|
||
public function testToString() | ||
{ | ||
$previousSendmailPath = \ini_set('sendmail_path', ''); | ||
$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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should happen in |
||
$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); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will change the default behavior: before: |
||
} | ||
|
||
$this->stream = new ProcessStream(); | ||
|
There was a problem hiding this comment.
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()
.There was a problem hiding this comment.
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()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 sebastianbergmann/phpunit#5214
There was a problem hiding this comment.
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.