FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
Emails
Server Setup
Sieve Mail Filtering Setup
Topics
On this page
-
- Getting Started
- Git and File-System Layout (non-default setup)
- Version Constraints
- Managing Themes and Plugins (for entire WordPress site)
- Updating Themes and Plugins (for entire WordPress site)
- Adding Composer Support to Your Own Themes and Plugins (for developers)
- Using Composer to Manage Own Theme/Plugin Dependencies (for developers)
-
- Assigning Multiple IP Addresses to Single LAN Card
- Disable IPv6 on Ubuntu 12.04
- dsh – distributed shell
- fdupes – find & replace duplicate files with hardlinks
- GPG Keys Cheatsheet
- Increase "Open Files Limit"
- kill all php, nginx, mysql or any kind of processes
- Passwordless Authentication for SSH
- Screen
- search replace in multiple files useing grep xargs sed
- Setup sftp
- sysctl.conf
- Timezone Sync
- Using Google Public DNS on Ubuntu Server
- Using openssl to match private key, cerificate and CSR
- Configure Postfix to Use Gmail SMTP on Ubuntu
- Logrotate Example for Custom Logs
- PHP 5.5, MySQL, Postfix, Nginx and WordPress on Ubuntu
- Serverdensity
- Upgrade Ubuntu 10.04 to 12.04
- Using find and sed to replace strings in multiple files
- Webmin
-
- .my.cnf – mysql user & password
- Analyse slow-query-log using Anemometer
- Improving MySQL Query Cache
- MySQL Query Profiling
- Reset MySQL root password
- tuning-primer.sh – an alternative for mysqltuner
- Using MariaDB 10
- Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS
- Change WordPress Domain Name
- Character Sets and Collations
- Enable innodb_file_per_table
- Enable Remote Access (Grant)
- Installing Percona Toolkit
- Using tmpfs for temporary folder creation
- YARPP and InnoDB
- Convert MyISAM to InnoDB
- Using tmpfs for mysqldump & mysqlimport
- Convert from INNODB to MYISAM
- Analyse slow-query-log using mysqldumpslow & pt-query-digest
- mysqlcheck with cron to optimize automatically
- Using MySQLTuner to Optimize MySQL configuration
-
-
- Directly connect to PHP-FPM
- Generating core-dump for php5-fpm
- GeoIP
- Having php5 and php7 on same system.
- Install Xdebug and configure it with webgrind
- Installation of PHP Code Review Tools
- memcache
- PHP's Zend Opcache Config & Web Viewer
- Setting Sqlite support with PHP
- Using HHVM with PHP-FPM Fallback
- Using Redis for PHP Sessions on Ubuntu Server
- Installing PhpMyAdmin Quickly
- Moving PHP's session storage to tmpfs
- Install Xdebug and configure it with Netbeans
- Nginx – Enable PHP-FPM Status Page
- PHP-FPM: Socket vs TCP/IP and sysctl tweaking
- APC Cache Optimization & Monitoring Using Web Interface
- Checking if PHP/WordPress can send mails
- Debugging PHP Scripts Using slow_log and more
- Increase file upload size limit in PHP-Nginx
- Increase PHP script execution time with Nginx
-
- Performance Optimization
- Remove Query string of css/js files
- Setup ElasticSearch with ElasticPress
- Using Redis for WordPress Object-Cache
- WooCommerce Window Shopping Caching Technique
- Moving WordPress To New Server (Faster)
- Better wp-cron using linux's crontab
- 404 error- Page not Found!!!
- Debugging WordPress with Nginx
Installing packages for sieve and managesieve
Sieve-Dovecot Configuration
Enable sieve plugin support for dovecot-lmtp
Edit sieve dovecot-pluign configuration
Restart Dovecot
Global Sieve Rules
Create global sieve rules file
Enabling sieve plugin in roundcube
Enable sieverules plugin in roundcube config
Configure sieverules plugin to use correct managesieve service port
Testing
Sieve Mail Filtering Setup
This article covers:
- Email filtering e.g. showing trash can to newsletters who do not honor unsubscribe links automatically. This is like Gmail filters.
- Global spam filtering e.g. moving spam from inbox to junk folder (automatically)
Installing packages for sieve and managesieve
We are using dovecot pigeonhole project for sieve support.
apt-get install dovecot-sieve dovecot-managesieved
Please note that, installing sieve without spamassassin won’t filter spam messages automatically.
Sieve-Dovecot Configuration
Enable sieve plugin support for dovecot-lmtp
vim /etc/dovecot/conf.d/20-lmtp.conf
Add following:
protocol lmtp {
postmaster_address = admin@example.com
mail_plugins = $mail_plugins sieve
}
Edit sieve dovecot-pluign configuration
vim /etc/dovecot/conf.d/90-sieve.conf
Add following:
plugin {
sieve = ~/.dovecot.sieve
sieve_global_path = /var/lib/dovecot/sieve/default.sieve
sieve_dir = ~/sieve
sieve_global_dir = /var/lib/dovecot/sieve/
}
Restart Dovecot
Restart dovecot for changes to take effect:
service dovecot restart
You can see managesieve service running on port number 4190 by using telnet command:
telnet example.com 4190
Will output something like:
Trying 162.243.12.140...
Connected to test3.rtcamp.com.
Escape character is '^]'.
"IMPLEMENTATION" "Dovecot Pigeonhole"
"SIEVE" "fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave"
"NOTIFY" "mailto"
"SASL" "PLAIN LOGIN"
"STARTTLS"
"VERSION" "1.0"
OK "Dovecot ready."
You can find sieve commands here which you can run inside telnet shell to manage sieve filters. Or you can use following method to manipulate global sieve rules directly.
Global Sieve Rules
You can use sieve to implement/enforce server-wise rules/organization policies.
Create global sieve rules file
mkdir /var/lib/dovecot/sieve/
Then create/open global sieve rules files:
vim /var/lib/dovecot/sieve/default.sieve
Following example rules moves spam emails from Inbox to Junk folder automatically. X-Spam-Flag is added by spamassassin and amavis.
require "fileinto";
if header :contains "X-Spam-Flag" "YES" {
fileinto "Junk";
}
Change Ownership:
chown -R vmail:vmail /var/lib/dovecot
Compile sieve rules:
sievec /var/lib/dovecot/sieve/default.sieve
At this point you have sieve interpreter and managesieve service running.
Enabling sieve plugin in roundcube
Roundcube has 2 plugins for sieve:managesieve andsieverules.
Both provides similar functionality but I like support for extended mail-headers in UI provided by sieverules. So we will be using sieverules plugin.
Enable sieverules plugin in roundcube config
Open
vim /etc/roundcube/main.inc.php
Add sieverules to list of roundcube plugins
$rcmail_config['plugins'] = array('sieverules');
Configure sieverules plugin to use correct managesieve service port
Open
vim /etc/roundcube/plugins/sieverules/config.inc.php
Add/Update following line:
$rcmail_config['sieverules_port'] = 4190;
Testing
If you are using spamassasin, you can test global filters using this spam testing guide.
Amavis, Spamassassin & ClamAV Setup
PREVIOUS
Comments
Features
- Server Setup & Management
- Site Creation & Management
- Create WP Cloud Sites
- Speed & Caching
- Firewall Protection
- Backups & Recovery
- Logs & Monitoring
- Deployments & Developer Tools
- Team Access & User Permissions
Useful Links
Product
Other Products
Subscribe for curated product updates, tips, and announcements.
"*" indicates required fields
Name
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.