How do I move spam mail to spam folder?

Posted on in Categories , , , , , , , last updated May 29, 2007

Q. I want to move all mails tagged as spam to “spam” folder. How do I configure procmail to move spam mail to spam folder?

A. If you have Procmail and Spamassassin installed, then you can move mails using Procmail. It is a mail delivery agent (MDA) or mail filter, a program to process incoming emails on a computer, widely used on Unix systems

Configuration: PROCMAIL MOVE SPAM TO SPAM FOLDER

First, open ~/.procmail file (/home/you/.procmail):
$ vi ~/.procmail
Next append the following config code:
# All mail tagged as spam is moved to "spam" folder.
:0:
* ^X-Spam-Status: Yes
spam

Save and close the file.

Now all email tagged as spam will move to “spam” folder.

See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

4 comment

  1. Does anyone know how to setup postifx and procmail when there are no system users, only virtual ones in postfix? I need to be able to filter spam but users are virtual.
    Any ideas?

Leave a Comment