Home > CentOS, Vesta > Enable Roundcube filters in Vesta 0.98 on CentOS 6.6

Enable Roundcube filters in Vesta 0.98 on CentOS 6.6

#Install Dovecot Manage Sieve
yum install dovecot-pigeonhole

#edit 20-managesieve.conf
vi /etc/dovecot/conf.d/20-managesieve.conf

#Uncomment protocols
protocols = $protocols sieve

#Edit 10-master.conf
#add in section listed in blue

vi /etc/dovecot/conf.d/10-master.conf

service auth {
  unix_listener auth-client {
    group = mail
    mode = 0660
    user = dovecot
  }
  unix_listener auth-master {
    group = mail
    mode = 0660
    user = dovecot
  }

  user = dovecot
}

#Append this to the end of 10-master.conf
service managesieve-login {
  inet_listener sieve {
  port = 4190
  }
}
service managesieve {
}
protocol sieve {
    managesieve_max_line_length = 65536
    managesieve_implementation_string = dovecot
    log_path = /var/log/dovecot-sieve-errors.log
    info_log_path = /var/log/dovecot-sieve.log
}
plugin {
    sieve = ~/.dovecot.sieve
    sieve_global_path = /etc/dovecot/sieve/default.sieve
    sieve_dir = ~/sieve
    sieve_global_dir = /etc/dovecot/sieve/global/
}
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
protocol lda {
    mail_plugins = $mail_plugins autocreate sieve quota
    postmaster_address = postmaster@testdomain.com
    hostname = srv.testdomain.com
    auth_socket_path = /var/run/dovecot/auth-master
    log_path = /var/log/dovecot-lda-errors.log
    info_log_path = /var/log/dovecot-lda.log
}
protocol lmtp {
    mail_plugins = $mail_plugins autocreate sieve quota
    log_path = /var/log/dovecot-lmtp-errors.log
    info_log_path = /var/log/dovecot-lmtp.log
}

#touch and set the permissions on the log files, else you will get permission errors
touch /var/log/dovecot-lda-errors.log
chmod 660 /var/log/dovecot-lda-errors.log
chown dovecot.mail /var/log/dovecot-lda-errors.log

touch /var/log/dovecot-lda.log
chmod 660 /var/log/dovecot-lda.log
chown dovecot.mail /var/log/dovecot-lda.log

touch /var/log/dovecot-lmtp-errors.log
chmod 660 /var/log/dovecot-lmtp-errors.log
chown dovecot.mail /var/log/dovecot-lmtp-errors.log

touch /var/log/dovecot-lmtp.log
chmod 660 /var/log/dovecot-lmtp.log
chown dovecot.mail /var/log/dovecot-lmtp.log

#Create default sieve rule

mkdir /etc/dovecot/sieve
vi /etc/dovecot/sieve/default.sieve
require ["fileinto"];
# rule:[SPAM]
if header :contains "X-Spam-Flag" "YES" {
        fileinto "Spam";
}

touch /etc/dovecot/sieve/default.sieve
chmod +w /etc/dovecot/sieve/default.sieve
chown dovecot.mail /etc/dovecot/sieve/default.sieve

#Restart dovecot, if service starts, means configuration is successful
service dovecot restart

#Configure roundcube

vi /etc/roundcubemail/main.inc.php
$rcmail_config[‘plugins’] = array(‘managesieve’);

vi /usr/share/roundcubemail/plugins/managesieve/config.inc.php.dist

// default contents of filters script (eg. default spam filter)
$config[‘managesieve_default’] = ‘/etc/dovecot/sieve/default.sieve’;

#Configure Exim, modify part in purple
vi /etc/exim/exim.conf
localuser:
  driver = accept
  #transport = local_delivery
  transport = dovecot
  condition = ${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{true}{false}}

 

######################################################################
#                      TRANSPORTS CONFIGURATION                      #
######################################################################
begin transports

dovecot:
    driver = pipe
    command = /usr/libexec/dovecot/dovecot-lda -e -d $local_part@$domain -f $sender_address -a $original_local_part@$original_domain
    return_path_add
    log_output = true
    delivery_date_add
    envelope_to_add
    user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}
    group = mail
    return_output

#Restart exim, if service starts, means configuration is successful
service exim restart

Categories: CentOS, Vesta
  1. 3fofb2+cgzd9chmhn128@sharklasers.com
    March 19, 2016 at 1:10 am

    Worked perfectly!

  2. May 7, 2016 at 1:32 am

    I’m not one of going around commenting blogs, but after 48 hours of annoyance trying to get sieve to work with dovecot and roundcube and reading a billion websites and tutorials telling you to modify a WHOLE lot of files and lines….

    THIS. This did it on the first try, no fuzz, no hassle. Bam! Filters.

    Thanks a LOT Jeff. You’re bookmarked.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: