0

I'm using msmtp to deliver system email from an Ubuntu server via an SMTP account.

Can I somehow configure this setup to rewrite all emails to one specific recipient address? If so, how?

Or put differently, I don't want any arbitrary PHP script or otherwise to be able to send email to anybody that is not me. I should be the only person that receives any email generated by any script on the server. All while only using msmtp (not using postfix or some other server).

chmac
  • 130
  • 5
  • `set_from_header on`: “‘on’ always sets a From header and overrides any existing one.” https://marlam.de/msmtp/msmtp.html – Henri Menke Sep 15 '21 at 14:52
  • I’m seeking a similar option for `to` headers? – chmac Sep 16 '21 at 16:31
  • What do you mean? Reading `To:` headers is not the default behaviour anyway. Just don't pass `-t` (`--read-recipients`) when invoking `msmtp`. – Henri Menke Sep 16 '21 at 16:36

1 Answers1

1

I don't think this is possible with msmtp. From the man page (emphasis mine)

Msmtp transmits mails unaltered to the SMTP server, with the following exceptions:

  • The Bcc header(s) will be removed. This behavior can be changed with the remove_bcc_headers command and --remove-bcc-headers option.
  • A From header will be added if the mail does not have one. This can be changed with the set_from_header command and --set-from-header option. The header will use the envelope from address and optionally a full name set with the -F option.
  • A Date header will be added if the mail does not have one. This can be changed with the set_date_header command and --set-date-header option.
  • When undisclosed_recipients is set, the original To, Cc, and Bcc headers are removed and replaced with "To: undisclosed-recipients:;".

The undisclosed_recipients features was added recently. It does not appear to alter delivery though.

If you only cared about all local addresses being sent to a specific recipient (e.g. [email protected]) then you could use the aliases option with file contents

default: [email protected]
Andrew Lowther
  • 424
  • 3
  • 5
  • Thanks, I hadn't found seen part of the man page, I think you've nailed it. I have my local aliases being rewritten, but scripts can still send mail to anywhere they want which is what I want to stop, I'll find another way. – chmac Sep 17 '21 at 18:00