Cun Zhang’s Blog

September 13, 2008

Auto-Sending Mail Under GNU/Linux

Filed under: Uncategorized — Tags: , — Cun Zhang @ 17:08

Recently I’m running a matlab program which may need several days. And I don’t hope to login remote host many times to see whether  it is done, which is  a bad thing for me.

I hope when it’s done  there will be a mail for me. A mail client is working on my PC all the time, so I can see it.

I asked google if there is a solution for my problem. And I found it in many pages with the same content. And I can’t find who is the author for it. So bad!

The Solution:

You should install mutt and msmtp, and configure them right, and add your auto-sending scipt(I written it by bash) to cron.

And Debian GNU/Linux, it’s so easy.

Install mutt and msmtp via apt-get command:

sudo apt-get install mutt msmtp

The following is my configuration(you need replace user and domain.com to your mail account and server):

cunzhang@node31:~$ cat .msmtprc

#user@domain.com
account usr@domain.com
host smtp.domain.com
from usr@domain.com
tls on
auth on
user usr@domain.com
password ****

cunzhang@node31:~$ cat .muttrc

set folder=”~/.mail”
set mbox=”~/.mail/inbox”
set mbox_type=maildir
set record=”~/.mail/sent”

set sendmail=”/usr/bin/msmtp -a usr@domain.com”
set realname=”cunzhang”
set use_from=yes
set editor=”vim”

Then test whether it works.Mine works fine.

I write a bash script to detect matlab’s process and send email to me when the process is gone. Add it to crontab which makes that script run 1 time  every2 hours.

 For more information, please see mutt, msmtp and crontab.

Powered by WordPress