<<<MacOS 10.10 Yosemite 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 these steps, thanks to Ryan Barclay for the information.

  1. Create a master sieve config file
    • Create a new directory and file
    • Add the following information
    • Set the file and directory protection
# 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
    
  1. Add the SPAM sieve conf include to the main config
    • Edit the sieve config file
    • Modify the sieve_before command as shown
# 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
    
  1. Ensure that the Junk Folder is automatically created and subscribed to by default
# sudo vi /Library/Server/Mail/Config/dovecot/conf.d/15-mailboxes.conf

Replace:
mailbox Junk {
    special_use = \Junk
  }

With:
mailbox Junk {
    auto = subscribe
    special_use = \Junk
  }
    
  1. Restart all Mail server services using the Server.app
  2. Ensure that SPAM is going into the Junk folder correctly.

The final changes I have made is to quarantine virus and spam mail and to setup notifications to the original recipients, the following commands and checks will achieve this

$ 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