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?

ADVERTISEMENTS

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:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
4 comments… add one
  • J.R. Oct 3, 2008 @ 8:39

    This didn’t work at all. I’m running:

    Debian Etch
    Postfix 2.3.8
    Spamassassin 3.2.5

    Anyone have any ideas?

  • mary Dec 10, 2010 @ 17:39

    I HAVE OUTLOOK EXPRESS TO GET MY E-MAILS
    I WANT TO PUT SPAM INTO A FOLDER TO DELETE.
    CAN ANY ONE HELP

  • c1n0t3 Aug 8, 2011 @ 12:37

    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?

  • mualla Nov 16, 2011 @ 8:29

    I would like to move spam from my email now , because the messages are not opening

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.