8

I am trying to get all my system emails to be forwarded to my gmail address, using msmtp 1.8.3 and /etc/aliases on debian. It works, but I get errors from gmail.

When I email root (via echo "hello world" | mail -s "forward me" root), I obtain 2 emails in the inbox of the gmail address:

  1. The expected forwarded email
  2. The following message from [email protected]
Address not found
Your message wasn't delivered to root@backupbox because the domain backupbox couldn't be found. Check for typos or unnecessary spaces and try again.
The response was:

DNS Error: 5452395 DNS type 'mx' lookup of backupbox responded with code NXDOMAIN Domain name not found: backupbox

Obviously, it is not surprising that gmail cannot reach root@backupbox, since from their perspective, backupbox is not a fully qualified domain name. I am however surprised, because I aliased all my system addresses to my gmail address.

Here is my msmtp configuration:

# /etc/msmtprc
defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account gmail
host smtp.gmail.com
from [email protected]
auth on
user me
password xxxxxxxxxxxxxxxx
account default : gmail
aliases /etc/aliases

Here are my system aliases

# /etc/aliases
default: [email protected]

How do I make sure that only the first email reaches me? For example, can msmtp rewrite root@backupbox as [email protected]?

user48678
  • 209
  • 2
  • 6

1 Answers1

0

Yes, msmtp can rewrite addresses exactly like this. I have a similar setup on my machine and

echo 'a test email' | msmtp root

works as expected.

Perhaps the issue is with the + symbol. Maybe it needs to be escaped in some way. I'd suggest trying it without a + to test. Although obviously as your question is from 2019 you've probably found another way by now!

AdminBee
  • 21,637
  • 21
  • 47
  • 71
chmac
  • 130
  • 5