You are not logged in.

#1 2020-01-04 01:05:13

Salkay
Member
Registered: 2014-05-22
Posts: 618

[Off-topic] Using msmtp to send both local and external mail

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:

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 wiki's recommendations. I've also edited /etc/msmtprc as necessary, including a reference to /etc/aliases. Can msmtp send to both local and external mailboxes?

Troubleshooting that I've tried

Msmtp is working fine at a base level, e.g. with

echo "test" | mail -s "test message" external@email.com

However, if I invoke /etc/aliases as per above, I get an error.

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

$ 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?

Last edited by Salkay (2020-01-04 03:23:28)

Online

#2 2020-01-04 01:59:38

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [Off-topic] Using msmtp to send both local and external mail

Is this machine a Raspberry Pi?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2020-01-04 03:22:52

Salkay
Member
Registered: 2014-05-22
Posts: 618

Re: [Off-topic] Using msmtp to send both local and external mail

Yep, I've just realised it's off-topic. Apologies.

Online

#4 2020-01-04 09:03:02

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: [Off-topic] Using msmtp to send both local and external mail

Salkay wrote:

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?

msmtp sends emails, to smtp server. it doesn't do any local delivery on its own, so you can only make the local machine be the server. so you might need some flavor of https://wiki.archlinux.org/index.php/Op … Local_mail or similar.

the linked question also seems to be primarily about aliases that in the end, resolve to a full email address anyway ( mailer-daemon -> postmaster -> root -> something@gmail.com )

Offline

#5 2020-01-04 23:34:54

Salkay
Member
Registered: 2014-05-22
Posts: 618

Re: [Off-topic] Using msmtp to send both local and external mail

Thank you @frostschutz! That was the general sense I got too. I'll investigate OpenSMTPD.

(FWIW the linked question doesn't entirely resolve to an external email address. Everything goes to root, but then root splits to both a user account and an external email. Thanks again!)

Online

Board footer

Powered by FluxBB