Archive

Archive for July, 2011

Running Crontab

July 25, 2011 Leave a comment

My Previous post talks about sending automated emails using mutt.

How do we automate this process say every hour
Then we setup crontab to get this up and running.
Below are few of the options which crontab gives.
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file.
Steps
  1. Enter: $ crontab -e
  2. If you have not configured EDITOR it will ask for it set which ever you are comfortable with.
  3. Enter your time to execute command information, below is how you give it.
———————————————-

———————————————-
# Every Minute
# m h dom mon dow command
* * * * * /home/ahmed/executeMyMuttScript.sh
———————————————-
# Every Hour at zero minute
# m h dom mon dow command
0 0-23 * * * /home/ahmed/executeMyMuttScript.sh
———————————————-
# Every Hour at 30th minute (1:30, 2:30, 3:30 …)
# m h dom mon dow command
30 * * * * /home/ahmed/executeMyMuttScript.sh
———————————————-
Categories: How To

Configure "mutt" to send mail over SMTP using Google Apps

July 21, 2011 Leave a comment

dot.muttrc Download this file

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.

  1. If you need to configure anything for mutt first look for .muttrc in your home directory ~/.muttrc
  2. If its not there you can create one.
  3. I have attached my .muttrc file you can use to configure your mutt. (change the email and password)
  4. Just download the dot.muttrc and save it as .muttrc in your home directory (/home/ahmed).
  5. 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.

use
$ mutt
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 :)” zubair.ahmed@emailid.com < /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://zubair.ahmed@smtp.gmail.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.com@smtp.gmail.com:587/
set smtp_pass = “yourDomainPassword”

Categories: How To