Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using sendmail to send a very simple email from a text file. Here is the text file:

to:test@someaddress.com
from:admin@hostname.tld
subject:Testing

test test test

Which I send with:

sendmail -t < mail.txt

The server I am running sendmail from is hostname.tld. Here is /etc/hosts:

12.34.56.78     hostname hostname.tld
127.0.0.1       localhost

Where 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.tld

When 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')dnl

But 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?

share|improve this question

2 Answers 2

When you are sending the email using a script on your local machine, then it is received from localhost. The public IP will be shown in the next Received:-line.

share|improve this answer
    
Are you saying that the only way to not have 127.0.0.1 is to send mail through an SMTP server, for example? Is it not possible to remove the Received line with 127.0.0.1 on it at all? Setting up a dedicated mail server for what I am doing is a bit overkill, I would much rather use sendmail and just be able to get rid of that line somehow. –  Cameron Ball Jun 18 '13 at 7:53
2  
I am saying that if you are using that method of sending your mail, that is the way that sendmail will correctly create its Received-header. (I also completely fail to see why this is a problem.) –  Jenny D Jun 18 '13 at 7:59
    
Apparently it can trigger anti-spam mechanisms on some email servers. –  Cameron Ball Jun 19 '13 at 2:20
up vote 0 down vote accepted

This was my solution:

/etc/hosts :

12.34.56.78     hostname.tld
127.0.0.1       localhost

/etc/mail/submit.mc :

FEATURE(`msp', `[12.34.56.78]', `25')dnl

(originally it had 127.0.0.1 instead of my public IP)

/etc/mail/sendmail.mc :

DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=12.34.56.78')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=12.34.56.78')dnl

(both of those lines originally had 127.0.0.1, changing it makes sendmail listen on your public IP instead of localhost).

Run the command:

make -C /etc/mail

Reload sendmail:

service sendmail reload

After sending my test email with:

sendmail -t < mail.txt

The header I didn't like now says:

Received: from hostname.tld (hostname.tld [12.34.56.78])

And there's no mention of localhost or 127.0.0.1 anywhere in the headers

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.