I'm using sendmail to send a very simple email from a text file. Here is the text file:to:test@someaddress.comfrom:admin@hostname.tldsubject:Testingtest test testWhich I send with:sendmail -t < mail.txtThe server I am running sendmail from is hostname.tld. Here is /etc/hosts:12.34.56.78     hostname hostname.tld127.0.0.1       localhostWhere hostname.tld is the fqdn of the server and 12.34.56.78 is the public IP of the server. /etc/hostname simply contains hostname.tldWhen I receive the email, I get this header:Received: from hostname.tld (hostname.tld [127.0.0.1])I don't want 127.0.0.1, I want the public IP to be there, but I can't get sendmail to use it no matter what I do. I've also edited /etc/mail/sendmail.mc to have the line:define(`confDOMAIN_NAME', `hostname.tld')dnlBut it does nothing.I've read so many threads where people have a similar problem but nothing seems to resolve it. What can I do?
localhost [127.0.0.1] in email headers
email;sendmail
Daemon mode vs. MSPThe annotation of the IP address you mentioned above is actually not a configuration of the sendmail server itself. If you look at a modern deployment of sendmail it's typically split into 2 components. The traditional server (daemon mode) and another server running in mail submission program mode (MSP). You can see this with a simple ps command:$ ps -eaf | grep sendroot     24488     1  0 21:10 ?        00:00:00 sendmail: accepting connectionssmmsp    24504     1  0 21:10 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueueThe first line is sendmail in daemon mode, the second is sendmail in MSP mode. You can always tell them apart because most distros that ship sendmail make the MSP variant run as a special user with lesser privledges.  Here's it's running on my CentOS 5.x server as user smmsp.NOTE: This is done to segregate the duties of handling mail submission (MSP) and mail delivery (daemon mode). Users connect to the MSP instance when they're sending mail with commands such as mail and mailx locally on the box.When dealing with sendmail on a Red Hat based distro such as CentOS, the configuration files are located here: /etc/mail. There are 2 files that we're interested in for this modification:/etc/mail/sendmail.mc/etc/mail/submit.mcThe first file controls the daemon mode server, while the second file is meant for the MSP server.Incidentally, these *.mc files aren't actual configuration files that the 2 servers use directly; in general sendmail configuration can be complicated. Given it's age and it's versatility it can be configured in a multitude of ways and so these *.mc files are pre-configuration files that get compiled into actual sendmail configuration files. The compiled versions of these files are also in the same directory:/etc/mail/sendmail.cf/etc/mail/submit.cfIt's usually wise to not make changes to these 2 files directly but rather make the changes through their corresponding .mc file. You typically edit the .mc files and then run the make command while inside the /etc/mail directory. Again this is a Red Hat-ism, to my knowledge, so another distro might make things differently.NOTE:* The .mc files are in a macro language called M4, so the tool to compiled them is of course called m4. You can manually compile these files with a command such as this:$ m4 /etc/mail/submit.mc > /etc/mail/submit.cfThis is all that's going on with the fancy make and Makefile files that Red Hat provides in the /etc/mail directory.Changes to submit.cfSo what changes do you need to make? The following line needs to be appended to the submit.mc file:CLIENT_OPTIONS(`Family=inet, Address=<your ip here>, Name=MTA')dnlBe sure to add your IP where it says <your ip here>. Once you've made this change you'll need to regenerate your submit.mc file.$ cd /etc/mail && makeOnce you've regenerated the .cf file you'll need to restart sendmail:$ /etc/init.d/sendmail restart-or-$ /etc/init.d/sendmail reloadFinal productAfter making the above change you'll be left with the following header. In this example my external IP address was 50.122.22.45, for example.Return-Path: <root@mail.sdom.com>Received: from mail.sdom.com (mail.sdom.com [50.122.22.45])    by sdom.com (8.14.3/8.14.3) with ESMTP id r5J188Gx018193    for <user@sdom.com>; Tue, 18 Jun 2013 21:08:08 -0400Received: (from root@localhost)    by mail.sdom.com (8.14.3/8.14.3/Submit) id r5J15ua4018000;    Tue, 18 Jun 2013 21:05:56 -0400Date: Tue, 18 Jun 2013 21:05:56 -0400Message-Id: <201306190105.r5J15ua4018000@mail.sdom.com>to:user@sdom.comfrom:admin@hostname.tldsubject:TestingX-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00    autolearn=ham version=3.2.5X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail.sdom.comX-Greylist: Sender is SPF-compliant, not delayed by milter-greylist-4.0 (sdom.com [127.0.0.1]); Tue, 18 Jun 2013 21:08:09 -0400 (EDT)test test testReferencesRed Hat documentation that discusses the setup of sendmailNew Configuration File, submit.cf