Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[IM] allow override broken mail defaults#760

Merged
barryo merged 2 commits into
inex:masterfrom
listerr:mailsettings
Dec 9, 2021
Merged

[IM] allow override broken mail defaults#760
barryo merged 2 commits into
inex:masterfrom
listerr:mailsettings

Conversation

@listerr
Copy link
Copy Markdown
Contributor

@listerr listerr commented Dec 3, 2021

Longer description

  • Add new option MAIL_SENDMAIL_PATH to override sendmail path where the defaults are not appropriate
  • sendmail -bs is the wrong option for this (crashes with error) should be sendmail -t

This is useful for dev, or where you just need it to do the right thing, for example msmtp/msmtpd replaces the envelope sender
for non-existent users with something inappropriate.

@barryo
Copy link
Copy Markdown
Member

barryo commented Dec 3, 2021

Hey @listerr - to merge this, I'd ask for two things please:

  1. remove the changes from .env.example. As explained in the issue, we're pushing smtp as the default production scenario and don't want to confuse and complicate the env file. Happy for you to add to .env.dev if that works for you?
  2. revert to the sendmail options as per the mail.php file:

-bs Stand-alone SMTP server mode. Read SMTP commands from standard input, and write responses to standard output.
-t Extract recipients from message headers. These are added to any recipients specified on the command line.

i.e. make it: 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs'),.

We don't support anything but smtp and will direct anyone with non-smtp mail requirements to Laravel support forums. In that situation, having something other than the default will add to confusion. The changes still get you exactly what you need out of it.

Hope that makes sense.

Also, for dev purposes, this https://usehelo.com/ is absolutely fantasic and works with smtp settings. Strongly recommend.

@listerr
Copy link
Copy Markdown
Contributor Author

listerr commented Dec 3, 2021

The reason I changed it is that /usr/sbin/sendmail -bs won't ever work because it's expecting it to be an SMTP session and that's not what IXP Manager/Laravel appears to do.

i.e. sendmail -bs is expecting to receive SMTP commands on STDIN, and responds on STDOUT:

Exim is the default MTA for Debian (and I think Ubuntu):

-bs
This option causes Exim to accept one or more messages by reading SMTP commands on the standard input, and producing SMTP replies on the standard output. The -bs option is also used to run Exim from inetd, as an alternative to using a listening daemon

What IXP Manager/Laravel actually does is pipe an RFC-2822 formatted message on STDIN and expect the sendmail emulation to just deal with it. (I.e, no SMTP protocol back-and-forth).

Therefore sendmail -t works and is what you want:

-t
When Exim is receiving a locally-generated, non-SMTP message on its standard input, the -t option causes the recipients of the message to be obtained from the To:, Cc:, and Bcc: header lines in the message instead of from the command arguments. The addresses are extracted before any rewriting takes place and the Bcc: header line, if present, is then removed.

The options are the same for sendmail compatibility.

@barryo
Copy link
Copy Markdown
Member

barryo commented Dec 3, 2021

The reason I changed it is that /usr/sbin/sendmail -bs won't ever work because it's expecting it to be an SMTP session and that's not what IXP Manager/Laravel appears to do.

i.e. sendmail -bs is expecting to receive SMTP commands on STDIN, and responds on STDOUT:

If that's the case, the better approach would be to address it with Laravel directly: https://github.com/laravel/laravel/blob/8.x/config/mail.php

When we do Laravel upgrades, part of what we do is also upgrade changes to the stock config files so it will flow through.

I've learnt (the hard way) that the more we move off the framework's path, the more pain it will bring downstream 😢

@barryo
Copy link
Copy Markdown
Member

barryo commented Dec 3, 2021

Note also that the next version of Laravel will switch from SwiftMailer so this may all change Rob. Perhaps you're just ahead of the curve 😉

@listerr
Copy link
Copy Markdown
Contributor Author

listerr commented Dec 3, 2021

Thanks. Submitted this to laravel as a proposed PR.

After we've upgraded things I think the issue preventing this from working might go away (TLS stopped working I think due to some cert issue?), though we try to use msmtp/msmtpd everywhere (unless the application needs incoming mail) and it's deployed automatically for all our VMs and they all point to one mailhost, rather than having every application with its own mail config.

@listerr
Copy link
Copy Markdown
Contributor Author

listerr commented Dec 9, 2021

This has now been fixed in Laravel for next release:

@barryo
Copy link
Copy Markdown
Member

barryo commented Dec 9, 2021

Congrats @listerr 🚀

@barryo barryo merged commit 4dea3a7 into inex:master Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants