How do I move spam mail to spam folder?

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


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.
* ^X-Spam-Status: Yes

Save and close the file.

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

See also:

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.