This discussion is locked
Joe Roback

Q: Global Sieve Script to move Junk mail (Snow Leopard Server)

I want to setup a global sieve script to move junk mail, marked by Spamassassin, to the user's Junk folder server side. The problem with client side is, clients like the iPhone have no filtering ability and are flooded with Junk mail when a client like Mail.app is running.

Setting email rules via the "EmailRules" built-in wiki/blog/calendar interface works. Custom rules and vacation rules.

The documentation seems weak, Snow Leopard Server uses outdated programs, so trying to go by Linux-based howtos is often pointless.

Can anyone explain to me how I would go about setting a global sieve script in Snow Leopard Server (using the default dovecot/postfix mail setup), to filter Junk mail to a user's Junk folder automatically.

Here is the sieve script I want to use

require \["relational", "comparator-i;ascii-numeric", "fileinto"\];
if allof (not header :contains "X-Spam-Score" "-", header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "4.5")
{ fileinto ".Junk"; }

I've added "add_header spam Score SCORE" to my /etc/mail/spamassassin/local.cf

Message was edited by: Joe Roback

MacBook Pro (17-inch 3.06Ghz/8GB/X25-M 160GB G2), Mac OS X (10.6.2), Ubuntu Linux (9.10) on 8-core Intel Xeon (Harpertown), Mac Mini Server

Posted on Feb 8, 2010 10:28 AM

Close

Q: Global Sieve Script to move Junk mail (Snow Leopard Server)

  • All replies
  • Helpful answers

  • by pterobyte,

    pterobyte pterobyte Feb 8, 2010 11:05 AM in response to Joe Roback
    Level 6 (11,101 points)
    Servers Enterprise
    Feb 8, 2010 11:05 AM in response to Joe Roback
    A simpler solution would be to use "plus addressing". postfix, amavisd and dovecot support it.

    In /etc/amavisd.conf, make sure you have
    $recipient_delimiter = '+';
    @addrextension_spammaps = ('Junk');
    and of course set kill_level and finalspamdestiny as needed.

    Make sure /etc/postfix/main.cf contains
    recipient_delimiter = +

    And since the default OS X configuration calls Dovecot deliver from Postfix, you will also need to enable the recipient and extension variables in the dovecot transport in /etc/postfix/master.cf (I believe there is a commented sample for this in the config file).

    This should also help:
    http://www.ijs.si/software/amavisd/amavisd-new-docs.html#addrext

    HTH,
    Alex
  • by Joe Roback,

    Joe Roback Joe Roback Feb 8, 2010 12:57 PM in response to pterobyte
    Level 1 (0 points)
    Feb 8, 2010 12:57 PM in response to pterobyte
    I'm a little confused how this would help. Wouldn't this just rewrite the email to go to user+Junk@mydomain.com? How does this help me get the message into the Junk folder on the server side?

    It seems like this solution allows me to either let the SPAM pass, or bounce/discard. I don't ever want to discard, since false-positives are possible. And PASS just puts it in the Inbox.

    I'd really like to emulate the Gmail way, SPAM is put in Spam/Junk folder, if user expects an email, but doesn't see one, they could look in the Junk folder to see if it was a false-positive and then mark it as not junk.

    I have the sieve script. The default sieve vacation script works great, but is per user. But, I just really would like to have this global rule on the server side, no matter how its done, sieve or otherwise.
  • by pterobyte,

    pterobyte pterobyte Feb 8, 2010 1:08 PM in response to Joe Roback
    Level 6 (11,101 points)
    Servers Enterprise
    Feb 8, 2010 1:08 PM in response to Joe Roback
    Wouldn't this just rewrite the email to go to user+Junk@mydomain.com? How does this help me get the message into the Junk folder on the server side?

    It would redirect any mail recognised as spam into the users junk mailbox/folder (on the server).

    It seems like this solution allows me to either let the SPAM pass, or bounce/discard. I don't ever want to discard, since false-positives are possible. And PASS just puts it in the Inbox

    Mails with a spam score between tag2 and kill level would be sent into the users junk mailbox/folder. Mails with a spam score above kill level would be discarded (if you set kill level to be >=8 for example, you can pretty much bet it will be spam, so why bother the user with it and if you are still paranoid you can set kill level even higher).

    If you really want to goe down the sieve route (adding complication and processing load), you will need to use an include rule, which again would require a per user sieve script including a global script.
  • by Joe Roback,

    Joe Roback Joe Roback Feb 8, 2010 2:14 PM in response to pterobyte
    Level 1 (0 points)
    Feb 8, 2010 2:14 PM in response to pterobyte
    Yep. Apologies. I miss read. I did the above and it is indeed working. One problem. Virtual domains. I am using postfix aliasing also. +Addressing works for the virtual domains, but the moving to the Junk folder only works with the default domain (users and aliases)

    For the postfix aliases, I have

    virtualaliasdomains = hash:/etc/postfix/virtual_domains
    virtualaliasmaps = hash:/etc/postfix/virtual_users

    in my postfix/main.cf, I've tried a few things, adding the following to postfix/main.cf, but no luck getting the virtual domains with the +Junk moving to the Junk folder.

    virtual_transport = dovecot

    with and without

    virtualmailboxdomains = myvirtualdomain1.com, myvirtualdomain2.com

    I've been testing by sending email from an outside account to user+Junk@domain.com, user+Junk@virtualdomain.com .. Maybe that test isn't valid? Now that I want spam to come, nothing has showed for the last hour..
  • by Joe Roback,

    Joe Roback Joe Roback Feb 8, 2010 3:15 PM in response to pterobyte
    Level 1 (0 points)
    Feb 8, 2010 3:15 PM in response to pterobyte
    Yea, testing the virtual domains by sending email to user+Junk@virtualdomain.com doesn't work as a valid test. I can confirm though with

    dovecotdestination_recipientlimit = 1
    virtual_transport = dovecot

    in my postfix/main.cf, all virtual domains, aliases, etc work with this method (making sure to reload postfix). I am so happy. Thanks. Much better solution than sieve script.

    PS. $satag2_leveldeflt in /etc/amavisd.conf is the value of the "Minimum Junk Mail Score" in Server Admin > Mail > Settings > Filters.
  • by pterobyte,

    pterobyte pterobyte Feb 9, 2010 12:42 AM in response to Joe Roback
    Level 6 (11,101 points)
    Servers Enterprise
    Feb 9, 2010 12:42 AM in response to Joe Roback
    Glad you got it sorted.

    PS. $satag2_leveldeflt in /etc/amavisd.conf is the value of the "Minimum Junk Mail Score" in Server Admin > Mail > Settings > Filters.


    Yes, however, adjusting it in Server Admin may set kill_level = tag_level which you do not want in your setup.