1 February 2013

Maildir bash script check for new mail

I've set up that tiny script and saved it as "newmail" in /usr/local/bin and added a line at the end of /etc/bash/bashrc

And here it is:

#!/bin/bash

if [ -d ~/.maildir ]
then
  newmail=`find ~/.maildir/new -type f | wc -l`
  if [ $newmail -gt 0 ]
  then
    echo "You have $newmail new mails."
  else
    echo "No new mail for you."
  fi
fi


This script works out-of-the-box for the Gentoo and Funtoo distro, YMMV.