Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

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.

share|improve this question

marked as duplicate by Bryan, Ward, mdpc, Kenny Rasschaert, Tom O'Connor Apr 7 '13 at 18:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
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 5 '13 at 21:38

2 Answers 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
share|improve this answer
    
The revaliases seems to be used for the To: address. I do have it set up as you've suggested. –  Roger Gilbrat Apr 5 '13 at 21:54
    
No, it is used for the FROM address. Try setting the FromLineOverride to NO. –  Sebastian Apr 5 '13 at 22:02
    
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 5 '13 at 23:25

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

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.