Hi,
there are some useful functions that can be implemented in i-MSCP directly
Spam To Junk
The i-MSCP panel already have a spam to junk implementation, but it works only if the user at the first time make a login through webmail and save the custom settings in RoundCube. To make working a default spam-to-junk filter to the users that does not make a login in webmail, here is the solution.
1) edit the /etc/dovecot/dovecot.conf file and add the following lines:
QuoteDisplay More
plugin {
# Begin Plugin::RoundcubePlugin::managesieve::1st
sieve = ~/dovecot.sieve
sieve_default = /var/lib/dovecot/sieve/default.sieve
sieve_dir = ~/sieve
sieve_global_dir = /var/lib/dovecot/sieve/
# Ending Plugin::RoundcubePlugin::managesieve::1st
quota = maildir:User quota
quota_rule = *:storage=1GB
quota_warning = storage=95%% quota-warning 95 %u
quota_warning2 = storage=80%% quota-warning 80 %u
}
exit and save
2) Create the default sieve dir, create a default sieve rule in and own it to the mail user
mkdir /var/lib/dovecot/sieve
nano /var/lib/dovecot/sieve/default.sieve
QuoteDisplay More
require ["fileinto"];
# rule:[Spam]
if header :contains "X-Spam-Flag" "YES"
{
fileinto "INBOX.Junk";
stop;
}
chown -R vmail:mail /var/lib/dovecot/sieve
3) reload/restart dovecot service
service dovecot restart
Source: https://rtcamp.com/tutorials/mail/server/sieve-filtering/
Imap IDLE
The Imap IDLE function is very useful to increase the battery life of mobile device. Many Imap clients, like K9 mail, implement a push-to-mail function in Imap that use the Idle function of Imap server. The default idle time in dovecot is set to 2 minutes, increasing this time to 29 minutes, as the rfc2177 say, many mobile device can improve the battery life
edit the /etc/dovecot/dovecot.conf file and add the following line:
QuoteDisplay More
# Protocols
!include_try /usr/share/dovecot/protocols.d/*.protocol
imap_idle_notify_interval = 29 mins
protocol imap {
mail_plugins = $mail_plugins imap_quota
}
reload/restart dovecot service
service dovecot restart
Source: https://peterkieser.com/2011/0…e-and-dovecots-push-imap/
Expunge Junk Folder
This function can delete the oldest spam email received and optimize the space assigned to the mail account (edit 12/11/2014: modified cronjob and search query in DB)
1) edit the file /etc/dovecot/dovecot-sql.conf and add this line at the end
Quoteiterate_query = SELECT mail_addr AS user FROM mail_users
now restart/reload dovecot service
2) Create a new cronjob like this:
crontab -e
Quote40 3 12 * * /usr/bin/doveadm expunge -A mailbox INBOX.Junk savedbefore 30d >/dev/null 2>&1
Source: http://wiki2.dovecot.org/Plugins/Expire
Hope this can help many users
Bye bye