Skip to content

[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

Closed
wants to merge 2 commits into from

Conversation

jtojnar
Copy link

@jtojnar jtojnar commented Sep 26, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets N/A
License MIT
Doc PR TODO

Not all environments have sendmail installed in /usr/sbin.
Let’s ask for the path using ini_get.
See also symfony/swiftmailer-bundle#302

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', '');
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.

{
$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().

@SzymonKaminski
Copy link
Contributor

Isn't this case of specifying sendmail_path covered by native transport?

@Seb33300
Copy link
Contributor

Seb33300 commented Sep 27, 2023

I think this feature already exists using the native DSN protocol: https://symfony.com/doc/current/mailer.html#using-built-in-transports

This was introduced by #36131 to fix that issue: #36842

@@ -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

@@ -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

@jtojnar jtojnar marked this pull request as draft September 30, 2023 23:42
@jtojnar
Copy link
Author

jtojnar commented Oct 1, 2023

Actually, the native transport is what I am looking for. Unfortunately it is not available in the Symfony version used by Wallabag (4.4).

@jtojnar jtojnar closed this Oct 1, 2023
@jtojnar jtojnar deleted the sendmail-fixes branch October 1, 2023 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants