Crontab and sSMTP

12,758

I had a similar problem. The answer for me was actually quite simple.

The user/environment under which cron executes could not find the ssmtp binary. Simply by adding the full path to it achieved success.

# m     h       dom     mon     dow     command
0       9       *       *       *       /usr/sbin/ssmtp [email protected] < /home/a/a-msg.txt
Share:
12,758

Related videos on Youtube

akarapatis
Author by

akarapatis

Updated on September 18, 2022

Comments

  • akarapatis
    akarapatis over 1 year

    My server is Ubuntu 12.04.3 Cron jobs are working fine. I can send emails through command line, either using mail, ssmtp or sendmail. I have set the correct email address on top of the crontab -e

    [email protected]
    
    * * * * *  echo blaaah
    

    But what I get in mail.log is

    sSMTP[4267]: 550 5.7.1 Client does not have permissions to send as this sender
    

    Which is strange as I am able to send email through command line. Any ideas?

    • Aurelia
      Aurelia over 10 years
      cron does run as root, right? You can try adding root to the mail group, but it shouldn't be required. usermod -a -G mail root
  • akarapatis
    akarapatis over 9 years
    I am aware of this solution. But it is only a workaround. I preferred a solution that applied to the whole crontab
  • meanbunny
    meanbunny over 8 years
    Been looking all over for this solution.
  • E.S.
    E.S. almost 6 years
    Hmm this didn't do anything for me. I assume the /usr/sbin/ssmtp [email protected] < xyz xyz refers to the stdout of your command. I get a 550 error this way. Am I missing some steps?