4

I have a web server that was blacklisted from sending email because it was responding to SMTP HELO with localhost.localdomain instead of the domain name of my server (we'll call it example.com). I was able to get the server to respond to the HELO with example.com by removing localhost.localdomain from my /etc/hosts file. However, now any time I try to send email to an address with the same domain name, sendmail is attempting to deliver the message locally instead of sending it via SMTP to our actual mail server (which is hosted at Rackspace).

I followed the advice here: Why sendmail is accepting mails for hostname not present in local-host-names file? and ran

echo '$=w' | sendmail -bt

And got:

[mail]
[162.243.XX.XXX]
mail
[mail.example.com]
mail.example.com
localhost
[127.0.0.1]
example.com

From what I understand, sendmail considers all of those domains local. I set DontProbeInterfaces=True in my sendmail.cf file. Now when I run

sendmail -bt
$=w

I get:

localhost
[127.0.0.1]
example.com

I also tried removing example.com from /etc/mail/local-host-names, but sendmail still thinks that example.com is local. How can I get sendmail to stop attempting local mail delivery for example.com email addresses?

EDIT:

echo '$j' | sendmail -bt

produces

example.com

EDIT:

I tried changing the hostname from example.com to example, but now my SMTP HELO response is localhost and it takes several minutes to send an email. According to this: https://www.digitalocean.com/community/questions/sendmail-is-slow-to-send-mail sendmail expects hostname to be the FQDN, but I'm being told that it should never be the FQDN. Which is it?

This is in my mail.log:

Jul 28 16:40:01 localhost sm-msp-queue[1679]: My unqualified host name (localhost) unknown; sleeping for retry
Jul 28 16:41:01 localhost sm-msp-queue[1679]: unable to qualify my own domain name (localhost) -- using short name
  • Could you include results produced by echo '$j' | sendmail -bt? Does it produce example.com? YES => change name reported by hostname --fqdn to www.example.com. – AnFi Jul 28 '15 at 16:37
  • @AndrzejA.Filip yes, echo '$j' | sendmail -bt produces example.com. I tried hostname --fqdn www.example.com but it just gave me the "Usage:" instructions. Also, I don't use www., does that matter? – Ben Harold Jul 28 '15 at 16:53
  • sendmail? May I see your time machine, dude? – poige Jul 28 '15 at 17:40
  • @poige My personal recommendation for sendmail (sendmail-8) is "keep" :-) – AnFi Jul 29 '15 at 19:50
5

Fix your server's hostname. No server should ever have a hostname equal to the naked domain name; this is but one of the many problems which occurs when you do this.

  • I tried changing the hostname, but now my SMTP HELO response is localhost and it takes several minutes to send an email message. – Ben Harold Jul 28 '15 at 20:44
  • Are you trying to use a Debian-based system?! – Michael Hampton Jul 28 '15 at 20:45
  • Yes, I'm on Ubuntu 14.04.2 LTS – Ben Harold Jul 28 '15 at 20:49
  • Better see the other answer, then; Debian-based systems that don't use systemd don't handle their own hostnames properly. The workaround is to reconfigure sendmail as given in Andrzej's answer. – Michael Hampton Jul 28 '15 at 20:51
3

In your case Sendmail adds auto-configured "this host (email) name" ($j) to list of local email domains ($=w). Sendmail uses name reported by hostname --fqdn.

Recomended fixes:
Do not use "named domain" as hostname (as suggested in Michael reply)
OR
Change name used by sendmail as "this host mail name"

0

After seeing the comment by @poige my sanity was restored:

Remove sendmail. Install postfix. There's a good tutorial here: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04

Then edit /etc/postfix/main.cf and remove the fully qualified domain name from the mydestination parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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