LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to ENABLE "you have new mail" (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-enable-you-have-new-mail-944097/)

pointer2null 05-09-2012 12:04 PM

How to ENABLE "you have new mail"
 
I've got my server set up to do a whole range of (semi) usefull things automatically and should any of them break it sents me (root) a nice email.

I've been trying without success to enable the "you have new mail" message that always used to be there but I can't get it working. Any ideas?

I've set MAILCHECK as someone said unsetting it disabled the notification but that didn't work.

Kustom42 05-09-2012 12:14 PM

Take a look at http://pic.dhe.ibm.com/infocenter/ai...s%2Fmailrc.htm.

You will need to edit the main mail.rc or create one in roots home dir(if it does not already exist). There you can specify your options.

pointer2null 05-09-2012 12:22 PM

Thanks, but that doesn't seem to say anything about enabling the "you have new mail" message. The mail system is working fine, but I have to type 'mail' each time I log in to check. I was just trying to get the new mail message to appear on login...

Kustom42 05-09-2012 12:31 PM

I believe you need to set the PAGER env variable in that mail.rc file.

pointer2null 05-09-2012 12:52 PM

login as: root
root@192.168.1.12's password:
Last login: Wed May 9 18:01:40 2012 from 192.168.1.7
[root@GDServer ~]# cat .mailrc
set PAGER
export PAGER
[root@GDServer ~]#

Still no "you have no mail" - there is mail as I sent it before logging out.

chrism01 05-09-2012 07:34 PM

http://linux.die.net/man/1/bash
Quote:

MAIL

If this parameter is set to a file name and the MAILPATH variable is not set, bash informs the user of the arrival of mail in the specified file.
MAILCHECK
Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking.
MAILPATH
A colon-separated list of file names to be checked for mail. The message to be printed when mail arrives in a particular file may be specified by separating the file name from the message with a '?'. When used in the text of the message, $_ expands to the name of the current mailfile. Example:
MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"'
Bash supplies a default value for this variable, but the location of the user mail files that it uses is system dependent (e.g., /var/mail/$USER).
See also http://linux.die.net/Bash-Beginners-...ect_03_02.html & search for 'mailcheck'

pointer2null 05-10-2012 01:12 PM

We seem to be missing the point.

I'm trying to get the system to check and tell me as soon as I log in.

MAILPATH tells it where to check
MAILCHECK tells it how often to check

These are already set correct:

[root@GDServer ~]# env | grep MAIL
MAILCHECK=60
MAIL=/var/spool/mail/root

What the system doesn't do is tell me when I log in.

E.g.

As things are now:
login as: root
root@192.168.1.12's password:
Last login: Wed May 9 19:57:18 2012 from 192.168.1.7
[root@GDServer ~]# mailx
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 4 messages 2 new 3 unread
U 1 root Wed May 9 18:01 20/771
2 Cron Daemon Wed May 9 19:48 27/1188 "Cron <root@GDServer> "
>N 3 wdtv box Wed May 9 22:55 29/1012 "virus-scan.05-09-12"
N 4 root Thu May 10 06:01 29/1021 "virus-scan.05-10-12"
& q
[root@GDServer ~]#

What I would like:

login as: root
root@192.168.1.12's password:
Last login: Wed May 9 19:57:18 2012 from 192.168.1.7
You have new mail!
[root@GDServer ~]#

chrism01 05-10-2012 06:53 PM

Ok, well here's a method based on pam/ssh http://www.freelists.org/post/loulug...eck-on-login,1 ; this uses a specific pkg http://dev.man-online.org/man1/mailcheck/ that you enable in eg /etc/profile

HTH


All times are GMT -5. The time now is 07:04 AM.