<<<MacOS 10.12 Sierra Guides>>>

Managing Spam

The task here is simple I want to setup some Server Side rules tht will automatically move Spam mail into the Junk folder, this can be achieved by following the steps shown below, thanks to Ryan Barclay for the information.

Updated:After having performed a clean El Capitan install and upgrade to Sierra, most of this was already there.

Check that the following file exists and contains the data shown

# sudo mkdir /var/lib/dovecot/sieve/
# sudo vi /var/lib/dovecot/sieve/default.sieve

require ["fileinto"];
# Move spam to spam folder
if header :contains "X-Spam-Flag" ["YES"] {
  fileinto "Junk";
  stop;
}

# sudo chown -R _dovecot:mail /var/lib/dovecot
# sudo sievec /var/lib/dovecot/sieve/default.sieve
    

Add the SPAM sieve conf include to the main config (This step I had to perform)

# sudo vi /Library/Server/Mail/Config/dovecot/conf.d/90-sieve.conf

#sieve_before =
#sieve_before2 =
#sieve_before3 = (etc...)
sieve_before = /var/lib/dovecot/sieve/default.sieve
    

Check that the Junk Folder is automatically created and subscribed to by default


# sudo vi /Library/Server/Mail/Config/dovecot/conf.d/15-mailboxes.conf

mailbox Junk {
    auto = subscribe
    special_use = \Junk
}
    

Restart all Mail server services using the Server.app

Ensure that SPAM is going into the Junk folder correctly.

These changes are optional and shown below arre the changes I have made is to quarantine virus and spam mail and to setup notifications to the original recipients.

$ sudo serveradmin settings mail:postfix:spam_quarantine = "spam@cougar.eu.com"
$ sudo serveradmin settings mail:postfix:virus_quarantine = "cougar.eu.spam@gmail.com"
$ sudo serveradmin settings mail:postfix:virus_action = "bounce" 
$ sudo serveradmin settings mail:postfix:virus_notify_admin = yes
$ sudo serveradmin settings mail:postfix:virus_notify_admin_email = "admin@cougar.eu.com"
$ sudo serveradmin settings mail:postfix:virus_notify_recipients = yes

$ sudo serveradmin settings mail | grep spam
mail:postfix:spam_quarantine = "spam@cougar.eu.com"
mail:postfix:spam_subject_tag = "***JUNK MAIL*** "
mail:postfix:mail_enabled_groups:_array_index:4 = "spam"
mail:postfix:spam_ok_locales = "en"
mail:postfix:spam_notify_admin_email = "junk-admin@example.com"
mail:postfix:black_hole_domains:_array_index:0 = "zen.spamhaus.org"
mail:postfix:spam_scan_enabled = yes
mail:postfix:spam_rewrite_subject = yes
mail:postfix:spam_notify_admin = no
mail:postfix:spam_ok_languages = "en fr de ja sw ta"
mail:postfix:spam_action = "deliver"
mail:postfix:spam_log_level = "warn"

$ sudo serveradmin settings mail | grep virus
mail:postfix:virus_db_last_update = "2015-01-12 07:42:51 +0000"
mail:postfix:virus_scan_enabled = yes
mail:postfix:virus_db_log_level = "info"
mail:postfix:virus_quarantine = "cougar.eu.spam@gmail.com"
mail:postfix:virus_log_level = "info"
mail:postfix:virus_notify_recipients = yes
mail:postfix:virus_notify_admin_email = "admin@cougar.eu.com"
mail:postfix:virus_action = "bounce"
mail:postfix:virus_db_update_days = 12
mail:postfix:virus_notify_admin = yes