Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I run a Postfix server with Amavis and Spamassassin among other things. Postfix receives mail from the outside world and passes it on to Amavis. Amavis has Spamassassin rate the mail, and then tags it as spam if necessary. Then Postfix relies on each users' procmailrcs to deal with the mail as they will. I believe this is the correct approach because I believe each user should have the ability to choose what to do with their spam. Unfortunately, we also have some users with foregin domains in our virtual alises list. Because these addresses don't have user accounts with our servers, the spam that is forwarded to them is never put through a procmailrc and we end up forwarding spam, already tagged as spam, to other servers. Is there a way to stop outgoing mail already tagged as spam? Or is there any other way to fix this?

EDIT: I only wish to delete the messages that are both spam AND being forwarded to other servers. I don't want to delete all mails marked as spam. Is there a way to distinguish between the two?

share|improve this question

1 Answer 1

You can delete emails with a particular tag in header.

See Postfix Header Checks Man page for details.

Example:

In "/etc/postfix/main.cf", add

header_checks = regexp:/etc/postfix/header_checks

In "/etc/postfix/header_checks", have

/^(Subject: \[SPAM\])(.+)$/ DISCARD

The above will discard all emails whose Subject starts with "[SPAM]".

EDIT: I only wish to delete the messages that are both spam AND being forwarded to other servers. I don't want to delete all mails marked as spam. Is there a way to distinguish between the two?

This could be done by running two instances within Postfix. The first instance will forward the email to second instance (instead of to Remote email server). The same can be achieved by specifying a local transport.

The second instance will have the above header_checks. This way only emails to remote server will have their SPAM deleted.

Some references:

  1. Specifying Transport
  2. You can run multiple instances of Postfix by specifying additional entries in master.cf file. Details here
share|improve this answer
    
An example might be nice. –  womble Jan 19 '10 at 5:48
    
The format did not come out ok. I have edited the answer –  Srikrishnan Chitoor Jan 19 '10 at 6:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.