LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Any way to show when an email has been received via command line... (https://www.linuxquestions.org/questions/linux-newbie-8/any-way-to-show-when-an-email-has-been-received-via-command-line-4175473343/)

trist007 08-14-2013 08:12 AM

Any way to show when an email has been received via command line...
 
Hello,

I am running Slackware 13.37. I use mainly mutt to check my mail. I am using Maildir format. Is there a way to where each time I hit enter on the command line it checks to see if I have any mail and if I do to display I have mail? Sort of like biff but I think biff only works for mbox.

-Tristan

jpollard 08-14-2013 05:37 PM

The problem depends on where the mail is, not the file format.

If you use a remote server to retrieve your mail from (most people do), then whatever method you want has to actually download any mail messages (or ask the server how many)... And that will require whatever method the server requires to login. This is slow.

If it is local mail (as in /var/mail/<username>) then it is simple - just look at the file, if the size is bigger than the last check, you have new mail. If it is smaller, mail has been read - and use the new size. This is what the bash shell does for checking.

See the manpage on bash - it handles maildir format as well as mbox files.

TobiSGD 08-14-2013 06:25 PM

Not sure about Bash, but Zsh knows the precmd (executed anytime before a prompt is printed) and preexec (executed anytime before the commandline is executed) functions, which could easily be used for your purpose. Of course it would be easier to run Mutt all the time in a different terminal/VT and check periodically for new mail manually.

chrism01 08-14-2013 07:31 PM

Try post #5 here http://ubuntuforums.org/showthread.php?t=878058 ?

EDDY1 08-14-2013 11:33 PM

I guess for gnome maybe this will work
http://ubuntuforums.org/showthread.php?t=195788

trist007 08-15-2013 09:41 AM

Great thanks.

trist007 08-15-2013 10:29 AM

For anybody interested, I found bash's solution. This of course assumes you are using bash as your shell.

Make sure these environmental variables are set

MAIL=~/Maildir
MAILCHECK=60

This will check your mailbox every 60 seconds and if you have mail it will display the next time you hit enter on the command line.

If you are using mbox make sure to use

MAIL=~/mbox

instead.

The reason it was not working for me earlier was because my MAIL variable was set to

MAIL=/var/mail/<username>

but once I changed it to my Maildir it worked.

Enjoy!

-Tristan

---------- Post added 08-15-13 at 10:29 AM ----------

For anybody interested, I found bash's solution. This of course assumes you are using bash as your shell.

Make sure these environmental variables are set

MAIL=~/Maildir
MAILCHECK=60

This will check your mailbox every 60 seconds and if you have mail it will display the next time you hit enter on the command line.

If you are using mbox make sure to use

MAIL=~/mbox

instead.

The reason it was not working for me earlier was because my MAIL variable was set to

MAIL=/var/mail/<username>

but once I changed it to my Maildir it worked.

Enjoy!

-Tristan

trist007 08-15-2013 10:34 AM

edit function hangs


All times are GMT -5. The time now is 05:26 PM.