Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

We are running an outbound SPAM filter, and we'd like to be able to have the mail sent through that filter, even when it's to a local user. Is there a way to force sendmail to use the SMART_HOST, even when it is going to be delivered locally?


Here's what I want. My host is If I send an email from (using SMTP) to, I want the email to go from to to, then back to Is this possible without creating an endless loop?

share|improve this question
up vote 1 down vote accepted

This sounds like a job for procmail as the LDA. Use it to invoke your spam filter for any locally generated email.

define(PROCMAIL_MAILER_PATH',/usr/local/bin/procmail') FEATURE(local_procmail_lmtp) MAILER(procmail) MAILER(procmailnoalias)dnl

and in your global procmail rule, look for an x-header not present to then send the mail through for scanning

e.g :0H * < 10000000 * !^X-Locally-Scanned: MySuperScanner

share|improve this answer
Good idea. I will look into this option. (Your formatting is a little off btw). – bradlis7 Mar 24 '10 at 18:39

Yes, you'll want to set the MAIL_HUB and LOCAL_RELAY options too. See the section titled MASQUERADING AND RELAYING in the Sendmail ReadMe.

Within Sendmail alone that's impossible (as far as I know). What you could do however is:

  1. Configure all local mail ( to forward all email to
  2. Configure a firewall rule to redirect any connections to 25/TCP and 587/TCP (and any other SMTP ports you're using) that don't originate from to (you'll need to include loopback as well as physical interfaces)

That, in theory, should catch almost everything but it may break things badly. I've no idea what'll happen if somebody calls sendmail locally. If you're running a webmail install check to see if you can configure it to send all email via instead of locally.

It may be simpler to integrate the spam filter in

share|improve this answer
But, I eventually want the mail to come back to the same host. Will this create an endless loop? See the example I added to the post. – bradlis7 Mar 24 '10 at 13:50
Good idea.. Now just to figure out what all I'll be breaking by doing this. And in my instance, I just want to forward local packets. The MX record, and the /etc/mail/access file takes care of everything else. – bradlis7 Mar 24 '10 at 18:31

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.