Open markstos opened 1 year ago
What msmtp can do is this:
set_from_header on
) To: undisclosed-recipients:;
(via set undisclosed_recipients on
)That should be enough to make all mail services accept the mail.
Yes, I currently do consider rewriting the headers to arbitrary values to be outside the scope of msmtp, because I think the above is sufficient -- but that does not mean that I cannot change my mind if you can explain why it's not sufficient ;)
External scripts can help, of course, but it's hard to prevent them from modifying the body of the mail instead of just the headers if a line in the mail body happens to start with From:
or To:
.
I looked into set undisclosed_recipients on
, but it sets the value unconditionally. I only would want something like that if the To/Cc/Bcc is a local address.
Msmtp currently does not offer this flexibility and configurability. For your use case I would recommend using postfix.
@marlam The combination of msmtp
along with the sendmail wrapper script above that I posted above is working fine for me. Ansible makes that customization easy to manage. I came from Postfix and was looking for something less complex.
It's up to the Ansible role maintainer whether they support a wrapper like that or not.
I'm reporting back that I've been testing the wrapper for about a year and it's been working fine.
Some Linux utilities will send mail from a local address with no @ sign, like "cron" , to a local email address like "root" (again, no "@" sign or domain).
While
msmtp
has features to alter the envelope sender and recipient, it doesn't alter the "To:" or "From:" message itself.When the Envelope doesn't match these details, it can be considered spam. AWS SES is an example of an SMTP service that won't accept mail addressed to "root", even if the Envelope recipient is valid. But sending out cron mails is exactly the kind of thing that
msmtp
should be good for!One issue about this in the
msmtp
bug tracker is here: https://github.com/marlam/msmtp-mirror/issues/98So I propose that the Ansible role introduce a small feature to address, since the
msmtp
maintainer considers it out of scope.I successfully tested the solution of adding my own
sendmail
wrapper. In my case, I hard-coded an email address to use, but a proper solution could use a template variable and a variable for this:Then in Ansible:
I tested this with the
mail
app (mailx) on Ubuntu 22. It relies on clients looking up sendmail in $PATH. If some place has hardcoded the path to /usr/sbin/sendmail, my fix wouldn't cover that since I don't replace that file.