Forcing email address cron is sent FROM [duplicate]
cron is using the sendmail
command to send mails. Normally the mailserver is appending the domain so in your case ssmtp would need to to that.
I never used sSMTP before but it's sender rewriting seems pretty strange. I looked at the source code and there is a file /etc/ssmtp/revaliases
.
The example lists this:
# 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.
In your case probably:
root:[email protected]:email-smtp.us-east-1.amazonaws.com:465
As it doesn't seem to be possible to change the From: address that cron sends from in Ubuntu, I have found a hacky solution. It's probably not the best way, but it does seem to work.
When ssmtp is installed, it creates a link from /usr/sbin/sendmail
to /usr/sbin/ssmtp
. What I did was delete the link and created a sendmail file that contains the following:
sed "s/From: root /From: [email protected] /" | /usr/sbin/ssmtp $*
Now any mail sent from root
will get rewritten to [email protected]