LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux mail command : -f param (https://www.linuxquestions.org/questions/linux-newbie-8/linux-mail-command-f-param-4175437120/)

jonaskellens 11-14-2012 09:20 AM

Linux mail command : -f param
 
Hello,

the following command works properly on 1 Linux (CentOS) box and not on another :

Code:

echo "test" | mail -s "subject" info@domain.tld -- -f noreply@domain.tld
On the working CentOS, this means that a mail is send to info@domain.tld and the mail seems to come from the sender noreply@domain.tld

On the not-working CentOS, the mail is send to the following recepients :
noreply@domain.tld
-f@servername.domain.tld
--@servername.domain.tld
info@domain.tld

The mail-addresses noreply@domain.tld, -f@servername.domain.tld, --@servername.domain.tld of course do not exist.


How can you explain the difference in the "-- -f noreply@domain.tld" parameter of the mail-command ??

chrism01 11-14-2012 07:19 PM

I'd check OS versions, update levels and env settings eg locale.
Maybe mail is symlinked to something else like mailx, nail etc

jonaskellens 11-15-2012 05:21 AM

On the working server, this is the situation :

-rwxr-xr-x 1 root mail 84856 jan 7 2007 mail
lrwxrwxrwx 1 root root 4 nov 16 2011 mailx -> mail

On the not-working server, this is the situation :

lrwxrwxrwx. 1 root root 5 okt 10 15:07 mail -> mailx
-rwxr-xr-x. 1 root root 378784 aug 22 2010 mailx

chrism01 11-15-2012 07:50 PM

Well, there you go :) , you're actually using 2 different 'mail' programs.
In fact, in mailx, the -f switch says
Quote:

-f [file]
Read in the contents of the user's mbox (or the specified file) for processing; when mailx is quit, it writes undeleted messages back to this file. The string file is handled as described for the folder command below.
which is not what you want.
Either use the same prog on both systems OR use the correct flags in each case.

jonaskellens 11-16-2012 01:45 AM

Chris,

is there an easy way to switch to using the mail-command also on server 2 ??

How can I reverse the symlink ?

jameshofmann 11-18-2012 08:24 AM

I'm not Chris, but I'm going to take a shot at this anyway.

"is there an easy way to switch to using the mail-command also on server 2 ??"

Yes. Remove the link on the second, "non-working" server that points the mail comand to mailx.

This will only work if the program "mail" is installed on the non-working server.

And it probably isn't. That's why there is a link from the command mail to the program mailx.

So my suggestion is to use mailx on the "non-working" server and mail on the other one.

Or, you can install mail on the second server.

Or (my preference, all other things being equal) you can install mailx on the first server and then only use mailx.

HTH, Jim

jonaskellens 11-25-2012 03:25 AM

How do I install the program "mail" ?

What I have installed is sendmail and mailx.

When I remove mailx on the second server, there is no mail-command also.

I have re-installed sendmail and mailx in different sequences, but I do not get the situation as on the working server.

chrism01 11-26-2012 01:09 AM

Quote:

When I remove mailx on the second server, there is no mail-command also.
That's because mail, is just a symlink on that system to mailx. If you remove mailx, obviously there's no mail(x) program to use.

Just install mailx on both and check you've actually got mailx as a program, not a symlink.
Maybe its a version issue; can you tell us what versions of Centos you have.
On my Centos 6.3, the default install is mailx as the real program and mail as a symlink thereto.

jonaskellens 11-26-2012 08:28 AM

You could be right.

Working CentOS : v5.8
Not-working CentOS : v6.3

I would like to use the simpel mail-command on both, not the mailx-command.

Is that possible ?

chrism01 11-26-2012 07:31 PM

A quick look through my 6.3 implies mail is no longer available
Code:

yum search  mail
yum info  '*mail*'

FYI in mailx the switch you want is -r http://linux.die.net/man/1/mailx

Feel free to try those cmds on both your systems.
You can always check the Centos site and look into the rpm downloads to double check.


All times are GMT -5. The time now is 04:10 PM.