LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 10:20 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Rep: Reputation: 33
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, 08:19 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
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, 06:21 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Original Poster
Rep: Reputation: 33
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, 08:50 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
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, 02:45 AM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Original Poster
Rep: Reputation: 33
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, 09:24 AM   #6
jameshofmann
LQ Newbie
 
Registered: Mar 2006
Posts: 6

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, 04:25 AM   #7
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Original Poster
Rep: Reputation: 33
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, 02:09 AM   #8
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
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 08:24 PM. Reason: typo
 
Old 11-26-2012, 09:28 AM   #9
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 620

Original Poster
Rep: Reputation: 33
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, 08:31 PM   #10
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

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


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


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration