LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 09:29 AM   #1
hudac
LQ Newbie
 
Registered: Oct 2012
Posts: 12

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, 11:11 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
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 11:12 AM.
 
1 members found this post helpful.
Old 01-31-2013, 12:40 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 08:46 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
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, 05:54 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

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

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
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, 01:08 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 08:48 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
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, 07:00 AM   #9
hudac
LQ Newbie
 
Registered: Oct 2012
Posts: 12

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, 10:33 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
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, 12:06 PM   #11
hudac
LQ Newbie
 
Registered: Oct 2012
Posts: 12

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, 07:13 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:35 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
Open Source Consulting | Domain Registration