LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   mailx change sender name (http://www.linuxquestions.org/questions/linux-software-2/mailx-change-sender-name-4175447850/)

hudac 01-30-2013 09:29 AM

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,

TB0ne 01-30-2013 11:11 AM

Quote:

Originally Posted by hudac (Post 4880731)
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'


chrism01 01-31-2013 12:40 AM

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... :)

TB0ne 01-31-2013 08:46 AM

Quote:

Originally Posted by chrism01 (Post 4881121)
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.

chrism01 01-31-2013 05:54 PM

Well, your profile says RHEL+Centos; try it on one of those? :)

TB0ne 01-31-2013 08:39 PM

Quote:

Originally Posted by chrism01 (Post 4881714)
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. :)

chrism01 02-01-2013 01:08 AM

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 ;)

TB0ne 02-01-2013 08:48 AM

Quote:

Originally Posted by chrism01 (Post 4881980)
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

hudac 02-03-2013 07:00 AM

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

I cant find "-r" in the manpage... :(

TB0ne 02-03-2013 10:33 AM

Quote:

Originally Posted by hudac (Post 4883533)
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??

hudac 02-03-2013 12:06 PM

Oh I forgot about it!

the
Quote:

mailx -s "Subject" user@domain.com -- -f from@domain.com < body
works!
Thanks!

chrism01 02-03-2013 07:13 PM

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 :)


All times are GMT -5. The time now is 01:02 AM.