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 have exactly the same problem as this. In a nutshell I am using mime::lite to send admin emails but they appear to be being flagged as spam because localhost[127.0.0.1] appears in the headers.

My question is how do I get rid of the references to localhost & 127.0.0.1 in the email headers?

The answer to the question linked to above was to install postfix, sadly this is already installed on the Fedora 14 host in question and it has not made any difference.

After the message has been set up this line is used to send the mails:


MIME::Lite->send("sendmail", "/usr/lib/sendmail -t -oi -oem -froot\@mail.mydomain.com");

I have tried various configurations within main.cf, myhostname is setup as 'mail.mydomain.com'. I tried explicitly setting 'myorigin = $myhostname' but, unsurprisingly as that is the default that did not make any difference.

In all the following examples and configs the real public IP address has been substituted with 1.1.1.1 and the domains as mydomain.com and mydomain1.com.

This is an example (edited) header with the offending bits in bold:



Return-path: <root@mail.mydomain.com>

Received: from smtpin.myisp.com ([10.30.30.30])
by ms.myisp.com (ISP server details removed (built Aug 10 2011))
 with ESMTP id <9XX8881234XX12X0@ms.myisp.com> for myname@myisp.com; Thu,
 13 Oct 2011 12:49:08 +0000 (GMT)
Original-recipient: rfc822;myname@myisp.com
Received: from mail.mydomain.com ([1.1.1.1.111])
 by smtpin.myisp.com (ISP server details removed (built Jan 31 2010))
 with ESMTP id <7YY11111Y1YY1YY1@smtpin.myisp.com> for myname@myisp.com
 (ORCPT myname@myisp.com); Thu, 13 Oct 2011 05:49:08 -0700 (PDT)
Received: from mail.mydomain.com (localhost [127.0.0.1])
    (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
    (No client certificate requested)   by mail.mydomain.com (Postfix)
 with ESMTPS id 6ZZ6Z6Z6666 for <myname@myisp.com> Thu,
 13 Oct 2011 12:49:02 +0000 (UTC)
Received: (from root@localhost)  by mail.mydomain.com (8.14.4/8.14.4/Submit)

This is the output from postconf -n:


alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
bounce_queue_lifetime = 1
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
local_recipient_maps = 
mail_owner = postfix
mailbox_command = 
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
maximal_queue_lifetime = 1
mydestination = mail.mydomain01.com, mail.mydomain.com
myhostname = mail.mydomain.com
mynetworks = 127.0.0.0/8 [::1]/128
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.7.5/README_FILES
sample_directory = /usr/share/doc/postfix-2.7.5/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550

This the contents of /etc/hosts:

127.0.0.1     localhost localhost.localdomain
1.1.1.1   mail.mydomain.com main.mydomain1.com mail

I can't post headers from a mail that has actually been marked as spam as mail to my real address is no longer marked as spam because I set the 'not junk' flag for email from our server. AOL is one of the (test) destinations and it is not possible to display headers using the AOL web interface. Mail sent to a gmail address simply does not arrive, I guess the server is kindly preventing delivery.

I checked using http://www.mxtoolbox.com, results vary for no apparent reason but our server address appeared (then disappeared again) on two lists because 'return codes were 127.0.0.6', which is odd because that particular loopback address has never appeared in our emails, unless postfix is doing something really weird, which seems unlikely.

If any other config data is required please let me know.

share|improve this question
    
Bad news. But what is the question? Where are examples? Where is the configuration? Where are the logs? Where is ... –  mailq Oct 13 '11 at 13:34
    
@mailq As requested, question clarification, examples & configs added. –  blankabout Oct 13 '11 at 14:21
add comment

2 Answers

up vote 1 down vote accepted

This is the only relevant line of your mail:

Received: from mail.mydomain.com ([1.1.1.1.111])
 by smtpin.myisp.com (ISP server details removed (built Jan 31 2010))
 with ESMTP id <7YY11111Y1YY1YY1@smtpin.myisp.com> for myname@myisp.com
 (ORCPT myname@myisp.com); Thu, 13 Oct 2011 05:49:08 -0700 (PDT)

And there is no indication of localhost at all. So your assumption that your mails are flagged as Spam based on the "localhost"-problem is not correct. It must be something different.

share|improve this answer
    
So are the references to localhost & 127.0.0.1 further down the header completely irrelevant? –  blankabout Oct 13 '11 at 15:45
    
Sure. Could be faked anyway. Not from you! But the following servers can't distinguish if they are real of faked. –  mailq Oct 13 '11 at 15:49
    
Thank you for the information. As you will have seen I have marked your answer as accepted but I have updated my question with the reason I originally thought that the loopback references were causing a problem so any further comments would be appreciated. –  blankabout Oct 14 '11 at 4:38
    
It's worth noting that some anti-spam scanners will indeed flag a message as spam if they find localhost or the loopback address in the headers. Just been through that pain myself. –  John Gardeniers Oct 14 '11 at 4:54
add comment

Are there more headers than you've supplied? I ask because if an email is being marked as spam by something like Spamassassin, it will add headers to the email stating what score it gave the email and what tests it 'failed'. If you have those headers and can post them, that will shed a lot more light on your problem. The headers I'm talking about typically have the word spam in them somewhere, for example

X-Spam-Status:
x-Spam-Score:

That type of thing.

If you're not seeing any spam headers in your email then it sounds to me like your email client itself is deciding that your emails are spam. How it determines that would be hugely dependent on what email client you're using.

share|improve this answer
    
There were, but the email I took the headers from wasn't marked as spam because I previously told my system that email from our server is 'not junk' and I can't get headers from other test emails that are flagged as spam for reasons I added to my question. I've also added the reason I originally thought that the loopback references were causing the problem. –  blankabout Oct 14 '11 at 4:36
add comment

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.