Configure host and default sender name in Linux sendmail

Run sendmail –s “TEST MAIL” < /dev/null. I find the following is gmail header :

Return-Path: <root@fedoralinux20-test>
Received: from fedoralinux20-test

Where can I change  the host name and domain name used by sendmail ?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dr. KlahnPrincipal Software EngineerCommented:
Sendmail is a bit of a drag as -- unlike Postfix -- the configuration files must be edited, and then recompiled.

Sendmail is, imo, overly obscure when compared to Postfix but if it's what you got, you may be stuck with it unless you can get permission to switch to Postfix.  Here's a good, brief introduction to Sendmail configuration.  (Ignore the references to the Redhat package manager.)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nociSoftware EngineerCommented:
By default the hostname is taken from the systems hostname, as return by the command  hostname
and the username the account that sends the mail.
To specify the sender <>  use the email address in conjunction with the -f option

I think you might be confusing sendmail with an email client such as mutt, mail

The configuration of the mail server, masquerade, defines the hostname that will be used when a message us being sent
There are env variables that can be set for sendmail to assemble the sender when one is not explicitly set.


Using external domain that you do not control such as gmail could be subjected by the receiving servers to the dkim, SPF, rules for the domain.


echo "To: emailaddress@domain
From: youremailaddress
Subject: test message

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

Open in new window

Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

AXISHKAuthor Commented:
My PHP website hosts on Apache server. Seem like it send out using user However, the apache user is not included in the php code. Any idea where will this user "apache" been setup ?

apache is the user under whose credentials httpd/apache web service runs.
you need to configure your php.ini mail to use the -f command with sendmail to set the email sender.
depending on how you are setting the message header in the PHP code, there is a way to identify who the sender should be .....
sendmail_path = /usr/sbin/sendmail -t -fsenderemail_address -oi

by default sendmail in the absence of the -f sendmail uses the logon as the username portion and its own hostname as the domain....
note the above will send all outgoing messages from your server using that sender....
AXISHKAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.