LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 11-14-2012, 09:20 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Rep: Reputation: 34
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 ??
 
Old 11-14-2012, 07:19 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I'd check OS versions, update levels and env settings eg locale.
Maybe mail is symlinked to something else like mailx, nail etc
 
Old 11-15-2012, 05:21 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
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
 
Old 11-15-2012, 07:50 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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.
 
Old 11-16-2012, 01:45 AM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
Chris,

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

How can I reverse the symlink ?
 
Old 11-18-2012, 08:24 AM   #6
jameshofmann
LQ Newbie
 
Registered: Mar 2006
Location: Missoula Montana US
Distribution: Debian
Posts: 8

Rep: Reputation: 0
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
 
Old 11-25-2012, 03:25 AM   #7
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
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.
 
Old 11-26-2012, 01:09 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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.

Last edited by chrism01; 11-26-2012 at 07:24 PM. Reason: typo
 
Old 11-26-2012, 08:28 AM   #9
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
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 ?
 
Old 11-26-2012, 07:31 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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.
 
1 members found this post helpful.
  


Reply



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
[SOLVED] How to send internal e-mail on Linux, using the mail command? sl33p Linux - Newbie 6 06-04-2009 08:13 PM
Debian etch - Unable to send mail from command line or from php mail command lqforumuser Linux - Newbie 1 03-01-2009 06:56 AM
Difference between HZ in linux/param.h and CPU clock cycle. drminix Linux - Hardware 0 05-26-2005 09:00 PM
[BASH] How to filter characters away? !{param#word} {param%word}! Dark Carnival Programming 8 03-17-2005 01:49 PM
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 06:06 PM

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

All times are GMT -5. The time now is 06:41 PM.

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