Monday, June 8, 2009

mutt - screen - fetchmail

As mutt does not print out new mail notification to xterm title for some reason (alpine and msnlib do), there is no easy way to notify the new mail if we are not on the mutt screen.  By using screen and fetchmail (together with a cronjob), we can get this resolved.

1. create ~/.fetchmailrc with this configurations:
poll mail.someserver.ca
proto IMAP 
user "your_username"
pass "your_password"

2. have this perl script in your ~/bin/ directory:
#!/usr/bin/perl
$_ = `fetchmail -c`;
s/(.*\)).*/$1/;
print;
 name it get_mail (chmod +x get_mail)


3. add this line into your crontab (scheduled for every 5 minutes):
*/5 * * * * ~/bin/get_mail > ~/bin/get_mail.out

4. edit your ~/.screenrc file to contain 2 lines like this:
caption always "%{+b bk}$USER@%{wk}%H | %{yk}(load: %l |%{rk} cpu: %1` | %{Gk}net: %2` | %{mk}mail: %3`) %-21=%{wk}%D %d.%m.%Y %0c"

backtick 3 150 150 cat /home/your_username/bin/get_mail.out  
the important part is: "%{mk}mail: %3`".  The 150 means 150 seconds.

With this, you will see the number of new emails in your screen status bar (within 5 minutes interval at most).

0 comments:

Post a Comment