LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 01-30-2013, 10:29 AM   #1
hudac
LQ Newbie
 
Registered: Oct 2012
Posts: 10

Rep: Reputation: Disabled
Post mailx change sender name


Hey,

I understood that for changing sender's name with "mailx" I should do the following:

Code:
mailx -r newmail@mail.com -s "some subject" my@email.com
But when I do that, I get:

Code:
mailx: invalid option -- r
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user
Does anyone knows what's happening? thanks,
 
Old 01-30-2013, 12:11 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,105

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by hudac View Post
Hey,
I understood that for changing sender's name with "mailx" I should do the following:
Code:
mailx -r newmail@mail.com -s "some subject" my@email.com
But when I do that, I get:
Code:
mailx: invalid option -- r
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user
Does anyone knows what's happening? thanks,
Yep...that option hasn't been supported for some time now. The mailx documentation is thorough, but complex. You've got a couple of options:
  • Something like
    Code:
    mailx -s "Subject" user@domain.com -- -f from@domain.com < body
    The double-dash tells mailx not to parse the -f, but just pass it along to sendmail/postfix, which will then set the "from" address accordingly
  • The -a switch, which supplies additional headersy, supplying a From: header on the command line that will be appended to the outgoing mail. In conjunction with the $REPLYTO environment variable specifies a Reply-To: header:
    Code:
    export REPLYTO=user@domain.com
    mailx -aFrom:user@domain.com -s 'Testing'

Last edited by TB0ne; 01-30-2013 at 12:12 PM.
 
1 members found this post helpful.
Old 01-31-2013, 01:40 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Hate to disagree with you, but mailx on my Centos 6.3 supports it (-r ) fully. Its both in the man page and it works; just tested it to be sure...
 
Old 01-31-2013, 09:46 AM   #4
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,105

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by chrism01 View Post
Hate to disagree with you, but mailx on my Centos 6.3 supports it (-r ) fully. Its both in the man page and it works; just tested it to be sure...
Huh...I had read it wasn't supported, and it doesn't work for me on my system. However, from the man page:
Quote:
Originally Posted by mailx man page
-r address
Sets the From address. Overrides any from variable specified in environment or startup files.
Tilde escapes are disabled. The -r address options are passed to the mail transfer agent
unless SMTP is used.
This option exists for compatibility only; it is recommended to set the from
variable directly instead.
The bolded part is what caught my eye. I'm puzzled though, since the man page DOES mention the "-r" being a valid option, but it does note it's only there for compatibility.
 
Old 01-31-2013, 06:54 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Well, your profile says RHEL+Centos; try it on one of those?
 
Old 01-31-2013, 09:39 PM   #6
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,105

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by chrism01 View Post
Well, your profile says RHEL+Centos; try it on one of those?
Yep...tried it on an RHEL6 server, and it didn't work, which is why I'm puzzled. Is the mailx executable on your box a link, or the actual mailx program?? I've seen links to "mail" from "mailx" before...but just grasping at straws here.
 
Old 02-01-2013, 02:08 AM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Code:
which mailx
  /bin/mailx
ll /bin/mailx
   -rwxr-xr-x. 1 root root 391224 Aug 22  2010 /bin/mailx


Would I lie to you
 
1 members found this post helpful.
Old 02-01-2013, 09:48 AM   #8
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,105

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by chrism01 View Post
Code:
which mailx
  /bin/mailx
ll /bin/mailx
   -rwxr-xr-x. 1 root root 391224 Aug 22  2010 /bin/mailx


Would I lie to you
Hey, I cast no dispersions your way! Was just trying to thing why it would behave differently. For me:
ll /usr/bin/mailx
-rwxr-xr-x 1 root root 361048 Feb 22 2011 /usr/bin/mailx
 
Old 02-03-2013, 08:00 AM   #9
hudac
LQ Newbie
 
Registered: Oct 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Unhappy

I have Red Hat 5.6, and It doesn't work.

I cant find "-r" in the manpage...
 
Old 02-03-2013, 11:33 AM   #10
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,105

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by hudac View Post
I have Red Hat 5.6, and It doesn't work.

I cant find "-r" in the manpage...
Ok...so go back and re-read post #2, where I gave you two different things to try. Did you try them??
 
Old 02-03-2013, 01:06 PM   #11
hudac
LQ Newbie
 
Registered: Oct 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Oh I forgot about it!

the
Quote:
mailx -s "Subject" user@domain.com -- -f from@domain.com < body
works!
Thanks!
 
Old 02-03-2013, 08:13 PM   #12
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Hey TB0ne, maybe its a version thing; here are my details
Code:
mailx -V
12.4 7/29/08

# OS
CentOS release 6.3 (Final)
Linux nodename 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
HTH
 
  


Reply

Tags
mail, mailx, sendmail


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
Unable to change the sender from root to user in postfix Pratique Linux - Server 9 06-28-2012 12:54 PM
Change sender address of outgoing emails in Sendmail ALInux Linux - Server 8 05-10-2012 07:25 PM
mailx change local domain nivek311 Linux - Newbie 1 01-16-2012 04:53 AM
Change sendmail's sender address rjo98 Linux - Newbie 17 06-18-2010 02:16 PM
PHP: How to change email sender per directory (apache vhost) ciuly Linux - Server 2 09-29-2009 03:21 AM


All times are GMT -5. The time now is 06:48 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration