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.

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?

Example

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

share|improve this question

2 Answers 2

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 (submit.mc) to forward all email to outbound.example.com
  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 inbound.example.com to outbound.example.com (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 outbound.example.com instead of locally.

It may be simpler to integrate the spam filter in mail.example.com.

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

 
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.