Search code examples
cronmutt

How to use cron with mutt to schedule a basic email?


I am new to both mutt and cron. It seems that mutt and cron are both working but I can't get them to work together.

I have the following in my crontab however I am not receiving an email from it:

* * * * *  echo "message body" | mutt -s "Test Email" email@email.com >/dev/null 2>&1

From the terminal I am able to use mutt to send an email using the following command:

echo "message body" | mutt -s "Test Email" email@email.com >/dev/null 2>&1

I can get cron to append text to a file by having the following in my crontab:

* * * * * echo "some text" >> /Users/me/Desktop/stuff.txt

EDIT: At the top of the crontab I have put MAILTO="email@email.com" Now each time the cron job runs I get an email from the Cron Daemon which reads:

/bin/sh: mutt: command not found


Solution

  • The path value needed to be set in the crontab:

    PATH="/usr/local/bin"