My Previous post talks about sending automated emails using mutt.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file.
- Enter: $ crontab -e
- If you have not configured EDITOR it will ask for it set which ever you are comfortable with.
- Enter your time to execute command information, below is how you give it.
My Colleague was working on having auto scripts to send mail through “mutt” with backup attachment.
But he was not able get it up, so though of looking into this.
Wondering what “mutt” is go here then 🙂
Here is what I did to get it working.
- If you need to configure anything for mutt first look for .muttrc in your home directory ~/.muttrc
- If its not there you can create one.
- I have attached my .muttrc file you can use to configure your mutt. (change the email and password)
- Just download the dot.muttrc and save it as .muttrc in your home directory (/home/ahmed).
- Also create directory in the path below
- mkdir -p ~/.mutt/cache/headers
- mkdir -p ~/.mutt/cache/bodies
- mkdir -p ~/.mutt/certificates
Before you can start using the script to send your mails –
you need to send the first mail from the “mutt client” so that it takes the certificate from the server.
This will bring up the mutt interface – send your test mail from here.
Once that is done. You are all set to use the script.
To test – run the below command in your command prompt.
$ mutt –help
$ mutt -s “Hello Test from the shell Script :)” firstname.lastname@example.org < /dev/null -a <attach a File here>
NOTE for .muttrc
# Non Google App users can just enter the username without the domain name like below.
#set smtp_url = “smtp://email@example.com:587/“
# To use google apps make sure your email account is transitioned – check with our Google Email Administrator
set smtp_url = “smtp://zubair.ahmed@domainName.firstname.lastname@example.org:587/“
set smtp_pass = “yourDomainPassword”