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?
 
Dr. KlahnConnect With a Mentor Principal 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
 
nociConnect With a Mentor Software 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
 
arnoldConnect With a Mentor Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.