1 (edited by rosolovsky 2016-04-09 02:22:29)

Topic: How can i redirect letters marked as spam into another mailbox

======== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.4
- Linux/BSD distribution name and version: CentOS 7 x64
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? no
- Related log if you're reporting an issue:
====
I have in /etc/postfix/main.cf:

header_checks = regexp:/etc/postfix/header_checks

and in /etc/postfix/header_checks

/^X-Spam-Flag: YES/ REDIRECT spam@mydomain.com

but it's absolutely not working for me!
Why not working "header_checks" in /etc/postfix/main.cf ?
How can i redirect letters marked as SPAM into another mailbox?
Thanks.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: How can i redirect letters marked as spam into another mailbox

Postfix header_checks is used before-queue, but email is marked as spam AFTER queued and scanned by Amavisd + SpamAssassin + ClamAV, so it won't work.

You need per-user sieve rule if you just want to do this for one user. Or, add sieve rule in global sieve rule file for all users in /var/vmail/sieve/dovecot.sieve.

3 (edited by rosolovsky 2016-04-10 14:42:50)

Re: How can i redirect letters marked as spam into another mailbox

ZhangHuangbin wrote:

Postfix header_checks is used before-queue, but email is marked as spam AFTER queued and scanned by Amavisd + SpamAssassin + ClamAV, so it won't work.

You need per-user sieve rule if you just want to do this for one user. Or, add sieve rule in global sieve rule file for all users in /var/vmail/sieve/dovecot.sieve.

In /var/vmail/sieve/dovecot.sieve i added the next strings for redirect:

require "fileinto";
if header :contains "X-Spam-Flag" "YES" {
  redirect "spam@mydomain.com";
} 

and i have a mail forwarding loop for spam@mydomain.com
How can i prevent mail forwarding loop?

4

Re: How can i redirect letters marked as spam into another mailbox

Try this:

if allof (header :contains "X-Spam-Flag" "YES", not header :contains "to" "spam@user.com")
{
    redirect ...;
}

Note: You can build sieve rules with Roundcube (Settings -> Filters).