Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Running Oracle Linux 5.8 (which is just re-branded RedHat EL 5.8) I must change the From address. But we have scripts that use mailx which cannot be re-written to use any extra flags, so I'd like to use internal variables instead, which I see on the manpage on mailx is an alternative to the -r flag:

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


How can we use these mailx variables? I tried adding this to /root/.mailrc, no go:


I also added that to /etc/mail.rc with no gold. So I am turning to you, SuperUsers...

share|improve this question

I just tested this in Ubuntu 14.04 and using the -S parameter worked for me:

-S variable[=value]
          Sets the internal option variable and, in case of a string option, assigns value to it.

So, the following command sets the from address to "":

echo "This is my test" | mail -S from="" -s "This is my subject" ""
share|improve this answer

Apparently it's not possible to set a mailx variable to do this. This is done with a Sendmail (or equivalent MTA) configuration. But unfortunately no Sendmail configuration was workable for us, and we have to use the -r flag.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.