LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-09-2012, 12:04 PM   #1
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Rep: Reputation: Disabled
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.
 
Old 05-09-2012, 12:14 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.
 
Old 05-09-2012, 12:22 PM   #3
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Original Poster
Rep: Reputation: Disabled
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...
 
Old 05-09-2012, 12:31 PM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
I believe you need to set the PAGER env variable in that mail.rc file.
 
Old 05-09-2012, 12:52 PM   #5
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Original Poster
Rep: Reputation: Disabled
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.
 
Old 05-09-2012, 07:34 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,241

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
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'
 
Old 05-10-2012, 01:12 PM   #7
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Original Poster
Rep: Reputation: Disabled
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 ~]#
 
Old 05-10-2012, 06:53 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,241

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl: how to save an e-mail attachment on disk keeping the "&" character (no "%26"!!) d1s4st3r Programming 5 09-29-2010 09:30 PM
Command "mail" returns "panic: temporary file seek" kenneho Linux - Software 5 12-23-2008 03:27 AM
How might I restore kmail folders/mail/settings from a "badly" saved "home"? deh6 Linux - Software 5 03-08-2008 09:25 PM
Help, after enable the "relay control" we can't receive the mail! explorer1979 Linux - General 1 11-28-2001 02:17 PM
Help, after enable the "relay control" we can't receive the mail! explorer1979 Linux - Distributions 1 11-22-2001 11:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration