Saturday, May 13, 2017

linux - Sendmail: Use SMART_HOST for local mail



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?


Answer



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


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...