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

I've got postfix setup so that mail coming in from smtpd is automatically filtered through spamassassin (which reinjects it into the mailqueue with added headers)

Now I want to do 2 things with messages that are considered spam:

  1. If the mail is outbound again (because of aliases) discard the mail on the spot
  2. If the mail is for a local virtual user hand it off to Dovecot which puts it in the Spam folder.

Can I configure postfix this way? All my alias and user information are in MySQL. Currently I discard all spam mail (with a header_checks in but I would prefer the above situation.

share|improve this question
great question. the first point would be very useful. – hayalci Jul 13 '09 at 13:36
up vote 4 down vote accepted

You could setup another smtp listener process in your to handle your outgoing mail. Something like the following should get you started with one listening on port 26:

26        inet  n       -       n       -       18       smtpd -o header_checks=[your checks] mydestination= relayhost=

You may need to tweak that slightly, to disable local delivery and not to accept mail from anywhere except localhost. You'd then want to add the following to your


And of course, drop your header checks out of that file.

Mail out would be relayed into the second smtpd process on 26 which would then drop messages that fail as spam. You can also specify a relayhost in that listener if you need pass your mail to a downstream server rather than delivering directly.

You'd then go about setting up the rest of your filtering for your local users with Dovecot like you'd already suggested.

You will of course want to consdier how many mail hops you add to your message when doing this as some mail providers will drop messages with a considerable number of hops (gmail for instance drops after something like 10 or 15

share|improve this answer
genuine msh technology! – Zanchey Jul 15 '09 at 13:57

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.