1

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).

3
  • set_from_header on: “‘on’ always sets a From header and overrides any existing one.” marlam.de/msmtp/msmtp.html Commented Sep 15, 2021 at 14:52
  • 1
    I’m seeking a similar option for to headers? Commented Sep 16, 2021 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. Commented Sep 16, 2021 at 16:36

1 Answer 1

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] 
1
  • 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. Commented Sep 17, 2021 at 18:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.