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[] appears in the headers.

My question is how do I get rid of the references to localhost & 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 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 ([])
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 ([])
 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 [])
    (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 = [::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:     localhost localhost.localdomain   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', 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.

  • 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

This is the only relevant line of your mail:

Received: from mail.mydomain.com ([])
 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.

  • So are the references to localhost & 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

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


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.

  • 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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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