I have configured my Debian server to use msmtp
for sending mails. Current use case are for example sending a daily report from logwatch
to my isp email.
echo "$body" | mutt -s "$topic" -- "myisp@email.com"
I have configured msmtp
by means of a global msmtprc
file located at /etc/msmtprc
. Contents shown below.
The next thing I want to configure is that my email for my root account (e.g., output from crontabs) is sent to my isp email as well.
I have googled around and found, for example on the Arch wiki, that I should just configure my aliases. Which I have done so at the bottom of the msmtp configuration file.
However, after running newaliases
, and trying to execute
echo test | mail -s "test message" root
I get the error
send-mail: /etc/aliases: line 2: invalid address 'postmaster'
Can't send mail: sendmail process failed with error code 78
I am unsure how I can fix this. The alias shown below is what was already present. I only added the gmail address.
I think I could just put a new aliases file but that might break other services that rely on this. I.e., I don't know what the proper way to fix this is.
/etc/aliases
# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: christphe, christophe.detroyer@gmail.com
/etc/msmtprc
# ------------------------------------------------------------------------------
# msmtp System Wide Configuration file
# ------------------------------------------------------------------------------
# A system wide configuration is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
# ------------------------------------------------------------------------------
# Accounts
# ------------------------------------------------------------------------------
account isp
host mail.isp.net
port 587
from admin@isp.com
auth login
user admin@isp.com
password foobar
syslog LOG_MAIL
logfile /var/log/msmtp.log
# ------------------------------------------------------------------------------
# Configurations
# ------------------------------------------------------------------------------
# Construct envelope-from addresses of the form "user@oursite.example".
#auto_from on
#maildomain fermmy.server
# Use TLS.
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
# Must be done within "account" sub-section above
#syslog LOG_MAIL
# Set a default account
account default : isp
aliases /etc/aliases
# ------------------------------------------------------------------------------#
root: christophe.detroyer@gmail.com
so I should create a/etc/aliases.msmtp
with just that line for the moment and change your config. Ismail
a link tomsmtp
? Do you have postfix or sendmail installed too?