I setup ssmtp to send email messages from my Ubuntu server to an external email address.
Using the mail command of the mailutils package, I am able to receive emails from my server sent via :
$echo test | mail -s test [email protected]
What I want to do now, is to send any message addressed to user root (like alerts and so on) to [email protected].
$echo test | mail -s test root
One of the most promissing solutions I found so far is :
sSMTP revaliases, aliases and mail.rc
As ssmtp is not able to forward and alias, the article tells one to use mail to alias addresses. But this also doesn't work. Indeed, I do not even have an /etc/mail.rc file in my filesystem.
It seems like the email has left the host, but never reaches the remote mail address.
Apr 19 19:46:16 hostname sSMTP[1160]: Creating SSL connection to host
Apr 19 19:46:16 hostname sSMTP[1160]: SSL connection using ECDHE_RSA_AES_256_GCM_SHA384
Apr 19 19:46:17 hostname sSMTP[1160]: Sent mail for [email protected] (221 2.0.0 Bye) uid=0 username=root outbytes=459
So far the summary. Now to the Question :
How to setup ssmtp and mail so that
$echo test | mail -s test root
will successfully send an email sent to root to an alias of root ?