mail command returns "Bad address"

Hi all.

Whenever I attempt to execute the mail command as a regular user I simply get a "Bad address" error on the command line like this:

[luser@myhost ~]$ mail
Bad address
You have mail in /var/spool/mail/luser

[root@myhost ~]# mail
No mail for root

I don't get anything in /var/log/maillog. Running the same command as root works fine, so this sounds like a permissions issue, but where?

The same holds true for mail -s. Non-root users just get "Bad address", root works fine.

Running "which mail" returns /bin/mail and the rights on /bin/mail are:
-rwxr-xr-x 1 root mail 82K Jan  7  2007 /bin/mail

The rights on /var/spool/mail are:
drwxrwxr-x  2 root   mail   4.0K Apr 14 15:24 mail

Both of these seem pretty standard, and should work. I've looked all around the web, and several others have posted this question with no real solution shown. I've already tried reinstalling sendmail using yum and it had no effect.

Any help will be appreciated.


vrodderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
Hi,

I'd suspect that the non-root users' mail command could be an alias.

What is the result of

alias mailwhence -v mail\mail

?

wmp
0
tty2Commented:
Try

gpasswd -a user mail
0
vrodderAuthor Commented:
Thanks for your replies. Here are the results for the commands you suggested:

[luser@myhost ~]$ alias mail
-bash: alias: mail: not found

[luser@myhost ~]$ ksh
$ whence mail
/bin/mail
$
-------------------------------

[root@myhost ~]# gpasswd -a luser mail
Adding user luser to group mail
[root@myhost ~]# su - luser
[luser@myhost ~]$ mail
Bad address

What else should I try?


0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

woolmilkporcCommented:
What is the output of
ls -l /var/spool/mail ?
Do all the mailboxes belong to their respective users and to the group "mail"?
Are their permissions at least "-rw-rw----"?
Is there a user whose mailbox you could safely delete, so that it gets recreated cleanly at the next mail arrival?
wmp
0
vrodderAuthor Commented:
I deleted the luser account (it's a test account) removed its home directory deleted its mailbox and removed it from /etc/group. Then I recreated it like so:

[root@netmon mail]# useradd -md /home/luser -s /bin/bash luser
[root@netmon mail]# passwd luser
Changing password for user luser.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@netmon mail]# gpasswd -a luser mail
Adding user luser to group mail
[root@netmon mail]# mail -s "test" luser@localhost.localdomain
Test
Cc:
[root@netmon mail]# ls -l luser
-rw-rw---- 1 luser mail 642 Apr 15 10:08 luser
[root@netmon mail]# su - luser
[luser@netmon ~]$ mail
Bad address
[luser@netmon ~]$

So still the same problem after removing and recreating the user.
0
tty2Commented:
Check configuration files: /etc/mail.rc, ~/.mailrc and some environment variables.
From man mail:
ENVIRONMENT
     mail utilizes the HOME, LOGNAME, USER, SHELL, DEAD, PAGER, LISTER, EDITOR, VISUAL, REPLYTO MAIL, MAILRC,
     and MBOX environment variables.
     If the MAIL environment variable is set, its value is used as the path to the user's mail spool.
0
vrodderAuthor Commented:
/etc/mail.rc is the default mail.rc file with the contents:
set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via

There is no .mailrc file in the user's home directory. If I'm correct this is no big deal since the .mailrc file contains user-specific settings beyond the defaults, which we don't use.

Environment variables apper to be correct...right?

[luser@myhost ~]$ env
HOSTNAME=myhost.mydomain.local
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
USER=luser
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
MAIL=/var/spool/mail/luser
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/luser/bin
INPUTRC=/etc/inputrc
PWD=/home/luser
LANG=en_US.UTF-8
SHLVL=1
HOME=/home/luser
LOGNAME=luser
CVS_RSH=ssh
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env
[luser@myhost ~]$
0
tty2Commented:
1st: Command "set" shows more about environment then "env"... But well. There are not all the variables, which mailx uses, in the output. Check these variables directly:
echo $DEAD
echo $PAGER
echo $LISTER
echo $EDITOR
echo $VISUAL
echo $REPLYTO
echo $MAIL
echo $MAILRC
echo $MBOX

2nd: run

ltrace mail

and analyze the output. If the phrase "Bad address" will be far above from the bottom of the screen, run

ltrace mail | less

and find this error message.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vrodderAuthor Commented:
That got it!!!

ltrace mail was the same as root until it got to this line:
open(NULL, 193, 0666)                            = -1

running as root the line read:
open("/tmp/RxJFWia4", 193, 0666)                           = 4

A quick check of the permissions on /tmp shows they were:
drw------- 6 root root 1.0K Apr 16 12:33 tmp

I don't know how the permissions on /tmp got changed to root only, but I changed them to world writable (777+t) and mail now works from all users.

Many thanks!



0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.