Solved

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

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

mail -s "Test" me@test.com ;

The command runs, but sends the email from root@testinglinux.com

Why does my Linux Box send email from "Root"? How can I change it to something more friendly?
0
Comment
Question by:devNOOB
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
jmarkfoley earned 500 total points
Comment Utility
Try:

mail -r someone@somewhere.com -s "Test" me@test.com ;

also read up on EXPOSED_USER (which root is normally configured as) https://www.sendmail.com/sm/open_source/docs/m4/masquerading.html
0
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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)
0
 
LVL 1

Expert Comment

by:jmarkfoley
Comment Utility
Arnold:
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 someone@somehost.com", and the local root sender is not on that host, then the header will contain:

X-Authentication-Warning: therealdomain.com: realuser set sender to someone@somewhere.com using -r

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

Open in new window

you would then do:

mail -A fairyprincess -s "Test" me@test.com

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

set hostname=webserver.domain.com

in /etc/Mutt/muttrc
0
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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.
0
 
LVL 76

Expert Comment

by:arnold
Comment Utility
Oh, you can use multiple muttrc_customized
mutt -f <muttrc> to differentiate sender set in different config files.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now