Configure host and default sender name in Linux sendmail

Run sendmail –s “TEST MAIL” test@gmail.com < /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 ?

Thx
AXISHKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

https://www.computernetworkingnotes.com/network-administrations/sendmail-server.html
0

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.
0
arnoldCommented:
To specify the sender <sender@yourdomain.com>  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.

/etc/mail/sendmail.cf

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.

Commonly,

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

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

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

Thx
0
arnoldCommented:
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....
0
AXISHKAuthor Commented:
Thx
0
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
Linux

From novice to tech pro — start learning today.