Skip to content

Instantly share code, notes, and snippets.

@William-Lake
Created January 7, 2018 13:35
Show Gist options
  • Save William-Lake/f50758f07a28f097fda78172379ecb63 to your computer and use it in GitHub Desktop.
Save William-Lake/f50758f07a28f097fda78172379ecb63 to your computer and use it in GitHub Desktop.
How to send an email via mutt in a bash script on a recurring basis with crontab.

How to send an email via mutt in a bash script on a recurring basis with crontab.

This was suprisingly difficult for me, so I'm making this quick guide so I have it handy in the future.

Steps

  1. Set up mutt using this guide
  2. Create your bash script that will be sending emails using mutt.
  3. When creating your bash script, add the following line to your mutt command:
    mutt -F /home/user/.muttrc ...
    Where /home/user/ is the path to your own configured .muttrc file in your home folder.
  4. Add your crontab:
    sudo crontab -e
    Using the following syntax:
    * * * * * /bin/bash /path/to/your/bash/script.bash >> /desired/path/to/logs/crontab_log.log 2>&1
  5. Reboot your machine.
  6. Check your crontab_log.log file to ensure everything went alright.

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment