I'm setting up email alert for unattended upgrades on ubuntu 18.04. It looks like unattended-upgrades cannot set the 'FROM' address and rely on mailx.
On mailx I'm using SMTP so the from address must be qualified. I get error that the from address is root and not [email protected]
To change this I need to set the 5th parameter in the root user in /etc/passwd file.
Is there no other less intrusive option?
EDIT: Adding ssmtp definitions (changed domain and user/pass for security)
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
[email protected]
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=email-smtp.eu-west-1.amazonaws.com:587
# Where will the mail seem to come from?
rewriteDomain=domain.com
# The full hostname
hostname=domain.com
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
# Use SSL/TLS before starting negotiation
TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
UseTLS=NO
UseSTARTTLS=YES
AuthUser=XXX
AuthPass=YYY
AuthMethod=LOGIN
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:[email protected]:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:[email protected]:email-smtp.eu-west-1.amazonaws.com:587
On Debian, I have found that using
mailx
command from themailutils
package generates wrong "From" domain address - it calls sendmail with "-f" parameter specifying just the hostname without any domain.When you install the
bsd-mailx
package, it provides its own version of themail
/mailx
binary (which should be set automatically as the default alternative). This internally calls "sendmail" without the "-f" parameter and (when mail server is configured properly) uses the correct full hostname + domain.