3

I'm running Ubuntu on AWS and am using their SES (Simple Email Service) and sSmtp to email logs since that is the only need for email on the server.

I have ssmtp sent up and everything works, except emails sent from cron jobs are being rejected due to the From: address. SES requires that the From: and To: email addresses be verified, but the email sent from cron and just root, not root@mydomain.com.

Is there a way to set the full email address that cron uses as the From: address, or is there a way to get ssmtp to rewrite the From: when it is a just a name with no domain?

My ssmtp.conf looks like this:

root=logs@mydomain.com
mailhub=email-smtp.us-east-1.amazonaws.com:465
rewriteDomain=mydomain.com
hostname=mydomain.com
#UseSTARTTLS=YES
UseTLS=YES
AuthUser=XXXX
AuthPass=XXXX
AuthMethod=LOGIN
FromLineOverride=YES

Thanks.

Roger Gilbrat
  • 251
  • 5
  • 9
  • 1
    It answers one part of my question, but doesn't address the part about is ssmtp can be configured to deal with naked username. – Roger Gilbrat Apr 05 '13 at 21:38

2 Answers2

2

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:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

In your case probably:

root:logs@mydomain.com:email-smtp.us-east-1.amazonaws.com:465
  • The revaliases seems to be used for the To: address. I do have it set up as you've suggested. – Roger Gilbrat Apr 05 '13 at 21:54
  • No, it is used for the FROM address. Try setting the FromLineOverride to NO. – Sebastian Wiesinger Apr 05 '13 at 22:02
  • 1
    For what ever reason, setting the FromLineOverride to NO causes SES to reject the emails. I am not sure why, but I found this advice when first setting it up and it solved the problem. – Roger Gilbrat Apr 05 '13 at 23:25
  • 1
    This answer is correct: configuring `/etc/ssmtp/revaliases` per @Sebastian's explanation, and setting `FromLineOverride=NO` in `/etc/ssmtp/ssmtp.conf` results in the sent emails being accept by Amazon SES. – Arto Bendiken Nov 13 '14 at 17:17
1

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: root@mydomain.com /" | /usr/sbin/ssmtp $*

Now any mail sent from root will get rewritten to root@mydomain.com

Roger Gilbrat
  • 251
  • 5
  • 9