Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After changing my sendmail setup, I've got most things working, but sendmail incorrectly sends email to "foo@localhost" to port 25, instead of delivering it locally. How to fix?:

  • Everything worked fine before the change, but I suspect was doing the work that does no.

  • When I email "foo@localhost", I want /usr/lib/sendmail to look in /etc/mail/aliases (or aliases.db), and do a local delivery to foo's target, which could be a local user, a pipe, a mailing list, etc.

  • I do NOT want /usr/lib/sendmail to pass foo@localhost emails to port 25. My port 25 is an stunnel: once an email reaches port 25, there's no hope of local delivery.

  • My /etc/hosts has " localhost.localdomain localhost", so I think sendmail parses "localhost" as "localhost.localdomain", but not sure.

  • Here are the localhost-related entries in (tabs compressed to single space for viewing purposes)

[if someone could cut/paste the content of this + the other URLs into this message, I'd be most appreciative; my attempts failed miserably]

  • And the localhost-related entries in (also tab-compressed)

  • The diff between the two (diff

  • Yes, I realize the duplicate "Cw" entry in both files is pointless, but it's never hurt, so I'm not worried about it yet.

  • I'm tempted to tweak's quoted lines to match's quoted lines, but I'd really like to understand what's going on before doing anything more. The hit-and-miss approach to *.cf editing is starting to worry me.

share|improve this question

You can start sendmail with the -Am switch and not use at all. Or you can have a sendmail daemon listen in some other port and then tweak to deliver there instead of port 25.

share|improve this answer

Your Answer


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.