-
-
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
Conversation
This was introduced in ee4192e to fix a NPE but sendmail will not work as a standalone SMTP server without the `-bs` flag. And the flag would initialize the `$transport` property to `SmtpTransport` object, which already stringifies as `smtp://sendmail`.
Not all environments have sendmail installed in `/usr/sbin`. Let’s ask for the path using `ini_get`. See also symfony/swiftmailer-bundle#302
@@ -38,10 +38,27 @@ protected function tearDown(): void | |||
|
|||
public function testToString() | |||
{ | |||
$previousSendmailPath = \ini_set('sendmail_path', ''); |
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.
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.
{ | ||
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
This should happen in tearDown()
.
Isn't this case of specifying |
I think this feature already exists using the |
@@ -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 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
@@ -83,7 +86,7 @@ public function __toString(): string | |||
return (string) $this->transport; | |||
} | |||
|
|||
return 'smtp://sendmail'; | |||
return 'sendmail://default'; |
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.
is that a bugfix? I think this should go on 5.4
Actually, the native transport is what I am looking for. Unfortunately it is not available in the Symfony version used by Wallabag (4.4). |
Not all environments have sendmail installed in
/usr/sbin
.Let’s ask for the path using
ini_get
.See also symfony/swiftmailer-bundle#302