Score:0

A script can send emails when I run it manually, but not when run by crontab

ki flag

I've written a script that emails me some information using ssmtp from an Ubuntu server. It works fine when I run it as root, but it fails when it's run with root's crontab.

I can see this error in the logs: Unable to set From="[email protected]"

This is my ssmtp.conf:

UseSTARTTLS=YES                                                                                  
[email protected]
mailhub=smtp.example.com:587
[email protected]
FromLineOverride=NO
rewriteDomain=example.com
[email protected]
AuthPass=xxxxxxxxxxx
AuthMethod=LOGIN

And revaliases:

root:[email protected]

Can someone help me understand what's different when I run it myself and when it's run by crontab, and how I can fix this problem?

Thanks in advance for the help!

nadrad avatar
ki flag
In case someone with a similar problem reads this in the future, no matter how much I tried, I couldn't fix it. Then, I switched from `ssmtp` to `msmtp`, and it worked.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.