Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Why does my Linux Box send email from "Root"? How can I change it to something more friendly?

Posted on 2015-02-05
Medium Priority
Last Modified: 2015-02-07
I am sending email from Ubuntu using the following command:

mail -s "Test" ;

The command runs, but sends the email from

Why does my Linux Box send email from "Root"? How can I change it to something more friendly?
Question by:devNOOB
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Accepted Solution

jmarkfoley earned 1500 total points
ID: 40592861

mail -r -s "Test" ;

also read up on EXPOSED_USER (which root is normally configured as)
LVL 79

Expert Comment

ID: 40592871
The default uses the username that is logged in and running mail as the sender.

Use a better mail client such as mutt or pine depending on your mail configurations.

Both inclue RC files where you can set the email address.

Mark pointed to an option that sets the reply-to, but I think the email will still be seen as coming from root since it is the account you are logged in with.

If this is part of a script using the option where you format the message and pipe it to
/usr/sbin/sendmail which is often a place holder to the installed mail server for backwards compatibility.

echo "To: some emailaddress
From: your emailaddress
Subject: testing

This is a test" | /usr/sbin/sendmail -fyouremailaddress -oi -t

The -t tells it to look through the data being pumped in to identify the recipients (To, Cc, Bcc)
-f sets the sender email address (envelope sender)

Expert Comment

ID: 40592996
Mark pointed to an option that sets the reply-to, but I think the email will still be seen as coming from root since it is the account you are logged in with.

No, that doesn't happen. If the -r name is also from the local host, e.g. "-r noreply", then there is no warning or other indication in any of the headers. If the -r name is to a remote host, e.g. "-r", and the local root sender is not on that host, then the header will contain:

X-Authentication-Warning: realuser set sender to using -r

You can also set the sender for mail[x] in $HOME/.mailrc
account fairyprincess {
    set from=" (John Doe)"
    set ORGANIZATION="Princess Products"

Open in new window

you would then do:

mail -A fairyprincess -s "Test"

This eliminates the X-Authentication-Warning warning. However, Arnold is correct to the extent that the "hidden" mail headers will always contain the real sender not to mention the Received: path hosts ... as they should!

I use mutt and mail both, mail more extensively. Mutt is great for encoding html, but I struggled with getting the equivalent of the -r option going (no -r in mutt). For mutt, it always sent the local LAN domain name no matter what I tried even though hostname -f returned the correct FDQN. Finally, I solved that by putting


in /etc/Mutt/muttrc
LVL 79

Expert Comment

ID: 40593008
You can have a local config .muttrc in the home and there you can define the from email address that will be used.

The /etc/Mutt/Muttrc  is a system wide configuration.

In the local .muttrc
My_hdr  from
Or setting from will set the sender.
LVL 79

Expert Comment

ID: 40593017
Oh, you can use multiple muttrc_customized
mutt -f <muttrc> to differentiate sender set in different config files.

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question