On a previous, Debian-based system, I used exim to send system mail (e.g. from cron) to both local mail and an external email account. Hence, /etc/aliases was set up like this:
$this->bbcode_second_pass_code('', '
mailer-daemon: postmaster
postmaster: root
www-data: root
...
root: pi
pi: pi, external@email.com
')
This meant that all mail was sent to both pi's local mailbox, and also to the external account.
I've since installed Arch on my server, and instead installed msmtp, msmtp-mta, and s-nail, as per the Arch wiki's recommendations. I've also edited /etc/msmtprc as necessary, including a reference to /etc/aliases. It it possible for msmtp to send to both local and external mailboxes?
Troubleshooting that I've tried
Msmtp is working fine at a base level, e.g. with
$this->bbcode_second_pass_code('', '
echo "test" | mail -s "test message" external@email.com
')
However, if I invoke /etc/aliases as per above, I get an error.
$this->bbcode_second_pass_code('', '
$ echo "test" | mail -s "test message to root" root
sendmail: /etc/aliases: Too many redirects when expanding alias root.
')
Despite the message referring to root, I thought that maybe msmtp didn't like the recursive pi to pi redirect. So to test, I removed the pi line. If I now try to send to pi directly, I get a different error.
$this->bbcode_second_pass_code('', '
$ echo "test" | mail -s "test message to pi" pi
sendmail: recipient address pi not accepted by the server
sendmail: server message: 550 5.1.1 <pi>: Recipient address rejected: User unknown in local recipient table
sendmail: could not send mail (account default from /etc/msmtprc)
')
Presumably msmtp is connecting to the external SMTP server, and attempting to send to the faulty email address "pi". I tried things like sending to pi@localhost and pi@<hostname>. Neither showed an error, but neither were delivered locally.
The msmtp page and the wiki only show examples of aliases directing to external addresses, but this suggests that local mail may be possible. Is it indeed possible to configure msmtp to send local mail?