Dovecot

From Indie IT Wiki

Dovecot is an open source IMAP and POP3 email server for Linux/UNIX-like systems, written with security primarily in mind. Dovecot is an excellent choice for both small and large installations. It's fast, simple to set up, requires no special administration and it uses very little memory.

HOWTO: DISABLE:

SSLv3 (POODLE)

sudo nano /etc/dovecot/conf.d/10-ssl.conf

ssl_protocols = !SSLv2 !SSLv3 TLSv1.1 TLSv1.2
sudo service dovecot restart

https://www.vultr.com/docs/disabling-sslv3

Standard IMAP Port 143

This will stop Dovecot from opening non secure port 143 and only use secure port 993...

sudo nano /etc/dovecot/dovecot.conf
     inet_listener imap {
        # address = *
        port = 0
     }

Or

sudo nano /etc/dovecot/dovecot.conf
     protocols = imaps

sudo nano /etc/dovecot/conf.d/10-master.conf
     inet_listener imap {
        port = 0
     }

Then, restart the software...

sudo service dovecot restart
sudo /etc/init.d/dovecot restart

HOWTO: INSTALL:

Releases

Latest: 2.3.11.3 / 2020-10-08 13:47

https://dovecot.org/releases/

Upgrading

Upgrading Dovecot v2.2 to v2.3

Ubuntu 18.04

sudo -i
apt install apt-transport-https
touch /etc/apt/trusted.gpg.d/dovecot.gpg
curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import
gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg
echo "deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main" > /etc/apt/sources.list.d/dovecot.list
apt-get update
apt-get check
apt-get --simulate dist-upgrade 
apt-get dist-upgrade
dovecot --version
dd if=/var/lib/dovecot/ssl-parameters.dat bs=1 skip=88 | openssl dhparam -inform der > /etc/dovecot/dh.pem
echo "ssl_dh=</etc/dovecot/dh.pem" >> /etc/dovecot/conf.d/10-ssl.conf
service dovecot restart
tail /var/log/mail.log

Ubuntu 16.04

sudo -i
apt install apt-transport-https
touch /etc/apt/trusted.gpg.d/dovecot.gpg
curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import
gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg
echo "deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/xenial xenial main" > /etc/apt/sources.list.d/dovecot.list
apt-get update
apt-get check
apt-get --simulate dist-upgrade 
apt-get dist-upgrade
dovecot --version
dd if=/var/lib/dovecot/ssl-parameters.dat bs=1 skip=88 | openssl dhparam -inform der > /etc/dovecot/dh.pem
echo "ssl_dh=</etc/dovecot/dh.pem" >> /etc/dovecot/conf.d/10-ssl.conf
service dovecot restart
tail /var/log/mail.log

Repositories

Ubuntu Packages / 14.04 + 16.04 + 18.04 + 20.04

On Ubuntu Server

This will install the IMAP daemon for Dovecot, with a self-signed SSL certificate.

sudo aptitude install -v -y dovecot-imapd
(type in the fully qualified hostname of your server when prompted, and press return)

Change the configuration files...

/etc/dovecot/dovecot.conf
listen = *
/etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/.maildir
/etc/dovecot/conf.d/10-auth.conf
#!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext

Restart dovecot...

service dovecot restart

Let's Encrypt SSL Certificate and Dovecot

Make sure you use the FULLCHAIN file now as the goalposts have moved...

sudo nano /etc/dovecot/conf.d/10-ssl.conf
ssl_cert = </etc/letsencrypt/live/domain.co.uk/fullchain.pem
ssl_key = </etc/letsencrypt/live/domain.co.uk/privkey.pem

sudo systemctl restart dovecot
sudo dovecot restart

openssl s_client -CAfile /etc/letsencrypt/live/domain.co.uk/fullchain.pem -connect localhost:993 -quiet

SSL Secure Certificate Installation (Paid For)

Switch to root user...

sudo -i

Create directories...

mkdir -p /root/misc/ssl/2016/dovecot

Change to directory...

cd /root/misc/ssl/2016

Create your CSR, send to ssls.com and wait for .zip file back.

Copy your Certificate and the 3 Root Certificates into 1 file...

cat domain_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > dovecot/dovecot_STAR_domain_com.crt

Copy your Key file into 1 file...

cat domain_com.key > dovecot/dovecot_STAR_domain_com.key

Put the Certificate and Key files into the OpenSSL directories...

cp -av /root/misc/ssl/2016/dovecot/dovecot_STAR_domain_com.crt /etc/ssl/certs/
cp -av /root/misc/ssl/2016/dovecot/dovecot_STAR_domain_com.key /etc/ssl/private/

Edit the Dovecot configuration...

nano /etc/dovecot/conf.d/10-ssl.conf

ssl = yes
ssl_cert = </etc/ssl/certs/dovecot_STAR_domain_com.crt
ssl_key = </etc/ssl/private/dovecot_STAR_domain_com.key

Start the server...

service dovecot restart

SSL Certificate (Self Signed)

openssl req -new -x509 -days 3650 -nodes -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem

nano /etc/dovecot/conf.d/10-ssl.conf

HOWTO: Restrict To Localhost

sudo nano /etc/dovecot/conf.d/10-master.conf
service imap-login {
  inet_listener imap {
    address = 127.0.0.1
  }
}

Thanks - https://serverfault.com/questions/262103/configure-dovecot-to-only-let-localhost-connect-via-imap

HOWTO: Delete All Dovecot Index Files

find /home/user/.maildir/ -type f -name 'dovecot.index*' -print -exec rm -rf {} \;

HOWTO: List User Mailbox Folders

doveadm mailbox list -u user@domain.com

HOWTO: Count User Mailbox Folder Messages

doveadm mailbox status -u user@domain.com messages Drafts

HOWTO: Create Mailbox Folder

doveadm mailbox create -u user@domain.com Fish

http://wiki2.dovecot.org/Tools/Doveadm/Mailbox

HOWTO: Delete Messages

Delete ALL messages...

doveadm expunge -u *@example.com mailbox Trash all

Delete messages older than 2 weeks...

doveadm expunge -u *@example.com mailbox Junk savedbefore 2w

HOWTO: Show Subject and Date Of Messages Containing X

doveadm search -u user@domain.co.uk BODY 'phrase or words to search for' | while read guid uid; do doveadm fetch -u user@domain.co.uk "hdr.subject date.saved" mailbox-guid $guid uid $uid; echo "===================="; done

https://wiki.dovecot.org/Tools/Doveadm/Search

HOWTO: Test Login Credentials Via Command Line

Using the password on the command line is optional. If you leave it off, it will ask you for the password...

doveadm auth test username [password]
doveadm auth test emailaddress@domain.com [password]

Testing the encryption method, using the raw database value...

doveadm pw -t '{SHA512-CRYPT}$6$Pzd6eFVy4Q5t$g6m7QypfTA8zw60zjiw08KDjGt7CGDno8gtW8mDn0pIkuzXYA7/7xccbwg.Y.txN32wBe4ny5iOIsafFhOWrf0'

Enter password to verify:

{SHA512-CRYPT}$6$Pzd6eFVy4Q5t$g6m7QypfTA8zw60zjiw08KDjGt7CGDno8gtW8mDn0pIkuzXYA7/7xccbwg.Y.txN32wBe4ny5iOIsafFhOWrf0 (verified)

HOWTO: Move Messages

doveadm move -u email@account DESTINATION mailbox SOURCE search query

e.g.

doveadm move -u user@domain.com 2015 mailbox Sent BEFORE 1-Jan-2016 SINCE 1-Jan-2015

http://wiki2.dovecot.org/Tools/Doveadm/Move

HOWTO: FIX:

dovecot: auth-worker: Fatal: master: service(auth-worker): (core dumped)

For some reason, the PAM module is now broken. After turning on verbose auth logging, the reason was shown...

dovecot: auth-worker(4660): pam(user,192.168.0.40): pam_authenticate() failed: Authentication failure (password mismatch?)

Change the system authentication module to 'shadow' by commenting out the 'pam' option...

nano /etc/dovecot/conf.d/auth-system.conf.ext
#passdb {
  #driver = pam
  # [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=<n>]
  # [cache_key=<key>] [<service name>]
  #args = dovecot
#}
passdb {
  driver = shadow
  # [blocking=no]
  #args =
}

Error: auth: pam_unix(dovecot:auth): authentication failure

auth: pam_unix(dovecot:auth): check pass; user unknown
auth: pam_unix(dovecot:auth): authentication failure; 

This is because you are sending login details which the Linux PAM Authentication system cannot understand, because you are using the 'passwd' style of user@domain.com auth login.

To fix, just comment out the 'system-auth' option from the Dovecot configuration file...

sudo nano /etc/dovecot/conf.d/10-auth.conf
     #!include auth-system.conf.ext

...and restart Dovecot.

sudo service dovecot restart

AfterLogic WebMail Speed Issue With Large Mailboxes

In static/js/app.js file, locate the following line:

setTimeout(_.bind(this.getAllFolderCounts, this, iAccountId), 2000);

and replace it with:

setTimeout(_.bind(this.executeCheckMail, this, iAccountId), 2000);

Note that app.js file isn't used by default - its minified version app.min.js is used. To change that, add the following item to the array defined in data/settings/config.php file:

'labs.use-app-min-js' => false,

Also, be sure to clear browser cache to apply changes.

The effect of the modification is that list of folders is still obtained, but folder stats are only retrieved for primary folders.

AfterLogic WebMail Lite Autoresponder Missing

http://www.afterlogic.com/forum/forum_posts.asp?TID=4883

http://www.afterlogic.com/wiki/Use_Sieve_for_filtering_%28WebMail_Lite%29

Upgrade Error: invoke-rc.d: dangling symlink

find /etc/rc* -type l -iname '*dovecot*' -exec rm -iv {} \;
sudo apt-get -f install

Startup Script In Ubuntu Server

cd /etc/init.d/
sudo ln -s /lib/init/upstart-job dovecot
sudo update-rc.d dovecot defaults
sudo service dovecot start

HOWTO: Generate Encrypted Password For Users File

Dovecot version 1...

openssl passwd -crypt

Dovecot version 2...

doveadm pw -s CRYPT

HOWTO: SECURITY:

Secure Dovecot

disable_plaintext_auth = yes
ssl = required

Test Secure Connection / Test SSL Certificate

openssl s_client -connect localhost:imaps -CApath /etc/ssl/certs
openssl s_client -connect server:imaps -CApath /etc/ssl/certs

Secure Dovecot Using TLS Encryption

http://xmodulo.com/secure-mail-server-using-encryption.html

Default Ports

110: pop
143: imap
995: pop3s
993: imaps

Fetchmail To MailScanner To Sendmail To Dovecot LDA To System User (+ Sieve)

Fetchmail > MailScanner > Sendmail > Procmail > Dovecot > Sieve

Just create a ~/.procmailrc file in your user's home directory...

DEFAULT=$HOME/.maildir/
LOGFILE=$HOME/procmail.log
DELIVER="/usr/libexec/dovecot/deliver"
DROPPRIVS="YES"
:0 w
| $DELIVER

...and then check the server email logs for the entries...

Jul 30 16:56:47 server1 dovecot: lda(user): msgid=<0933320008058003531@mail.domain.com>: saved mail to INBOX

dovecot: lda(sieve): sieve: msgid=<201307151456.r6FEusZI017531@mail.server.com>: sent vacation response to <me@server.com>

http://wiki2.dovecot.org/procmail

http://binblog.info/2011/11/24/dovecot-lda-behind-procmail/

Postfix Dovecot Virtual Users

https://www.rosehosting.com/blog/mailserver-with-virtual-users-and-domains-using-postfix-and-dovecot-on-a-centos-6-vps/

Fetchmail To MailScanner To Dovecot LDA To Virtual User

To be done, after the one below!


NOTES:

The /etc/mail/virtusertable file

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch21_:_Configuring_Linux_Mail_Servers#Using_Sendmail_to_Change_the_Sender.27s_Email_Address

Sendmail To Dovecot LDA

Local > Sendmail > Dovecot LDA > Virtual User Maildir

Following - http://wiki2.dovecot.org/LDA/Sendmail

dovecot --version

2.0.19

sendmail -d0.1

Version 8.14.4

/etc/mail $ ls

access access.db aliases aliases.db authinfo authinfo.db helpfile local-host-names mailertable mailertable.db sendmail.cf sendmail.mc sendmail.mc.orig statistics submit.cf submit.mc trusted-users virtuserdomains

/etc/mail/sendmail.mc

divert(-1)
divert(0)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail-procmail.mc,v 1.2 2004/12/07 01:59:31 g2boojum Exp $')dnl
OSTYPE(linux)dnl
DOMAIN(generic)dnl
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA')
dnl DAEMON_OPTIONS(`Port=smtp,Addr=192.168.0.207,Name=MTA')
define(`ALIAS_FILE', `/etc/mail/aliases')
define(`STATUS_FILE',`/etc/mail/statistics')
define(`SMART_HOST',`[auth.smtp.1and1.co.uk]')
FEATURE(`authinfo',`hash -o /etc/mail/authinfo.db')
FEATURE(`access_db')
FEATURE(`always_add_domain')
FEATURE(`relay_entire_domain')
FEATURE(`accept_unresolvable_domains')
dnl FEATURE(`virtusertable')
FEATURE(`mailertable')
FEATURE(`smrsh',`/usr/sbin/smrsh')
FEATURE(`local_lmtp',`/usr/sbin/mail.local')
FEATURE(`local_procmail')
FEATURE(`limited_masquerade')
FEATURE(`masquerade_envelope')
MASQUERADE_AS(`littlefield.uk.com')
MASQUERADE_DOMAIN(`vmware-gentoo-server.littlefield.uk.com')
VIRTUSER_DOMAIN_FILE(`/etc/mail/virtuserdomains')
MAILER(dovecot)
MAILER(procmail)
dnl MAILER(smtp)
MAILER(local)

/usr/share/sendmail-cf/mailer/dovecot.m4

Mdovecot, P=/usr/libexec/dovecot/dovecot-lda,
          F=DFMPhnu9,
          S=EnvFromSMTP/HdrFromSMTP,
          R=EnvToSMTP/HdrFromSMTP,
          U=vmail:vmail,
          T=DNS/RFC822/X-Unix,
          A=/usr/libexec/dovecot/dovecot-lda -d $u

/etc/mail/local-host-names

vmware-gentoo-server.littlefield.uk.com
vmware-gentoo-server
localhost.localdomain
localhost

/etc/mail/virtuserdomains

littlefield.org.uk

/etc/mail/mailertable

littlefield.org.uk dovecot:localhost

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

service auth {
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
    group = vmail
  }

/etc/dovecot/users

test@littlefield.org.uk:{PLAIN}password

/home/vmail/

-rw------- 1 vmail vmail  50K 2012-08-05 21:56 fetchmail.log
drwx------ 4 vmail vmail 4.0K 2012-08-05 17:30 test@littlefield.org.uk

dovecot-lda

-rwxr-xr-x 1 root root 23K 2012-08-05 15:27 /usr/libexec/dovecot/dovecot-lda

test message

echo "message" |mail -s "test" -v test@littlefield.org.uk |sed 's/^/ /'

test@littlefield.org.uk... Connecting to [127.0.0.1] via relay...
220 vmware-gentoo-server.littlefield.uk.com ESMTP Sendmail 8.14.4/8.14.4; Thu, 9 Aug 2012 17:20:19 +0100
>>> EHLO vmware-gentoo-server.littlefield.uk.com
250-vmware-gentoo-server.littlefield.uk.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<root@vmware-gentoo-server.littlefield.uk.com> SIZE=51 AUTH=root@vmware-gentoo-server.littlefield.uk.com
250 2.1.0 <root@vmware-gentoo-server.littlefield.uk.com>... Sender ok
>>> RCPT To:<test@littlefield.org.uk>
>>> DATA
250 2.1.5 <test@littlefield.org.uk>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <test@littlefield.org.uk>... Connecting to localhost via dovecot...
050 <test@littlefield.org.uk>... Sent
250 2.0.0 q79GKJWt004166 Message accepted for delivery
test@littlefield.org.uk... Sent (q79GKJWt004166 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 vmware-gentoo-server.littlefield.uk.com closing connection

/var/log/mail.log

Aug  9 17:20:19 vmware-gentoo-server sendmail[4165]: q79GKJN9004165: from=root, size=51, class=0, nrcpts=1, msgid=<201208091620.q79GKJN9004165@vmware-gentoo-server.littlefield.uk.com>, relay=root@localhost
Aug  9 17:20:19 vmware-gentoo-server sm-mta[4166]: q79GKJWt004166: from=<root@vmware-gentoo-server.littlefield.uk.com>, size=406, class=0, nrcpts=1, msgid=<201208091620.q79GKJN9004165@vmware-gentoo-server.littlefield.uk.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Aug  9 17:20:19 vmware-gentoo-server sm-mta[4166]: q79GKJWt004166: to=<test@littlefield.org.uk>, ctladdr=<root@vmware-gentoo-server.littlefield.uk.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=dovecot, pri=30406, relay=localhost, dsn=2.0.0, stat=Sent
Aug  9 17:20:19 vmware-gentoo-server sendmail[4165]: q79GKJN9004165: to=test@littlefield.org.uk, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30051, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q79GKJWt004166 Message accepted for delivery)

/var/log/dovecot/dovecot-info.log

Aug 09 17:20:19 lda(test@littlefield.org.uk): Info: msgid=<201208091620.q79GKJN9004165@vmware-gentoo-server.littlefield.uk.com>: saved mail to INBOX

/var/log/dovecot/dovecot-debug.log

Aug 09 17:20:19 auth: Debug: Loading modules from directory: /usr/lib64/dovecot/auth
Aug 09 17:20:19 auth: Debug: passwd-file /etc/dovecot/users: Read 4 users
Aug 09 17:20:19 auth: Debug: master in: USER 1 test@littlefield.org.uk service=lda
Aug 09 17:20:19 auth: Debug: passwd-file(test@littlefield.org.uk): lookup: user=test@littlefield.org.uk file=/etc/dovecot/users
Aug 09 17:20:19 auth: Debug: master out: USER 1 test@littlefield.org.uk uid=1000 gid=1000 home=/home/vmail/test@littlefield.org.uk

Virtual Users

https://wiki.dovecot.org/HowTo/SimpleVirtualInstall

https://wiki.dovecot.org/HowTo/VirtualUserFlatFilesPostfix

https://help.ubuntu.com/community/PostfixDovecotSASL

Virtual Users + System Users

/etc/dovecot/conf.d/10-auth.conf

!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

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

service auth {
  unix_listener auth-userdb {
    mode = 0666
    #user = 
    #group = 
}

/etc/dovecot/conf.d/auth-passwdfile.conf.ext

passdb {
  driver = passwd-file
  args = scheme=CRYPT username_format=%u /etc/dovecot/users
}

userdb {
  driver = passwd-file
  args = username_format=%u /etc/dovecot/users
}

/etc/dovecot/users

user@domain.com:{PLAIN}mypassword:vmail:vmail::/home/vmail/user@domain.com:

/home/vmail

drwxr-xr-x  4 vmail        vmail 4.0K 2012-09-20 17:58 vmail

total 88K
drwxr-xr-x  4 vmail vmail 4.0K 2012-09-20 17:58 .
drwxr-xr-x 72 root  root  4.0K 2012-09-14 15:52 ..
-rw-------  1 vmail vmail 1.6K 2012-09-20 18:06 .bash_history
-rw-r--r--  1 vmail vmail  127 2011-07-11 16:44 .bash_logout
-rw-r--r--  1 vmail vmail  193 2011-07-11 16:44 .bash_profile
-rw-r--r--  1 vmail vmail  606 2012-09-19 16:56 .bashrc
-rw-------  1 vmail vmail    8 2012-09-20 17:58 .fetchmail.pid
-rwx------  1 vmail vmail  524 2012-09-19 17:12 .fetchmailrc
-rw-------  1 vmail vmail   87 2012-09-20 17:12 .lesshst
drwx------  2 vmail vmail 4.0K 2011-07-07 11:20 .ssh
-rw-r--r--  1 vmail vmail  43K 2012-09-20 18:13 fetchmail.log
drwx------  3 vmail vmail 4.0K 2012-09-20 17:58 user@domain.com

Fetchmail to Dovecot Deliver LDA to Virtual Users

Internet > Fetchmail > Dovecot LDA > Virtual User Maildir

This will show you how to fetch mail from the internet and deliver it to local virtual email users. This is like taking a backup of your IMAP folder. Again, I could not find a single web page on the internet which showed this, so I am writing it down now so that someone else doesn't spend 3 hours trying to figure it out. :-(

http://llg.cubic.org/docs/imapbackup.html

This example is using IMAP and keeping the emails in the internet server, but you could use POP and delete the emails on the server.

Install Fetchmail

emerge fetchmail

Create the Virtual Mail User

useradd -c "Virtual Mail User" -d /home/vmail -U -m vmail
passwd vmail

Create the Fetchmail config file for the user 'vmail' (created for the Virtual Users above) which will go and get then deliver the emails.

cd /home/vmail/
touch .fetchmailrc
chown vmail:vmail .fetchmailrc
chmod 0700 .fetchmailrc
nano .fetchmailrc

This is the magic config file. The Dovecot documentation showed dovecot-lda -f $FROM_ENVELOPE -d $DEST_USERNAME but I could not get this variable to work, so hard coded it instead... at least, for now.

/home/vmail/.fetchmailrc
set daemon 300
set logfile /home/vmail/fetchmail.log
set no bouncemail
set postmaster vmail
poll imap.domain.co.uk protocol imap
     username "test@domain.org.uk" password "mypassword" fetchall keep
     mda "/usr/libexec/dovecot/dovecot-lda -d test@domain.org.uk"
preconnect "date >> /home/vmail/fetchmail.log"

Create the user database file. To generate encrypted passwords, use doveadm:-

doveadm pw -s CRYPT
/etc/dovecot/users
test@domain.org.uk:{PLAIN}password
user@domain.org.uk:{CRYPT}r.oySJdXZSPyE

Your logs will now show something like the following:-

/home/vmail/fetchmail.log
fetchmail: 12 messages (11 seen) for test@domain.org.uk at imap.domain.co.uk.
fetchmail: reading message test@domain.org.uk@imap.domain.co.uk:12 of 12 (1426 header octets) (10 body octets) not flushed
Sat Aug  4 20:49:16 BST 2012
/var/log/dovecot/dovecot-info.log
Aug 04 20:49:17 lda(test@domain.org.uk): Info: msgid=<501D7BF9.7020604@domain.co.uk>: saved mail to INBOX

Sieve

This facility consists of 2 parts - the ManageSieve daemon and the Sieve plugins + scripts.

Add the relevant USE flags and re-install the package...

echo "net-mail/dovecot maildir managesieve sieve" >> /etc/portage/package.use
emerge -q dovecot

Uncomment the config file line to enable the ManageSieve daemon and port...

nano /etc/dovecot/conf.d/20-managesieve.conf
protocols = $protocols sieve
service managesieve-login {
  inet_listener sieve {
    port = 4190
}
nano /etc/dovecot/conf.d/15-lda.conf
protocol lda {
   # Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = sieve
}

Restart Dovecot...

/etc/init.d/dovecot restart

Check the port is open...

netstat -ntap |grep dovecot
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      32135/dovecot       
tcp        0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN      32135/dovecot       

http://wiki.dovecot.org/ManageSieve/Configuration http://wiki.dovecot.org/LDA/Sieve/Dovecot

Then install the Out Of Office extension for Thunderbird below...

Sieve Examples

require ["fileinto","vacation"];
# rule:[Out of Office]
if false # true
{
        vacation :days 1 :addresses "me@domain.co.uk" :subject "Out of Office" :from "me@domain.co.uk" "I am out of the office, but will reply on my return.";
}
# rule:[Spam]
if allof (header :contains "subject" "{Spam}", not header :contains "from" "@domain.co.uk")
{
        fileinto "Spam";
}
# rule:[Fish]
if header :contains "subject" "Fish"
{
        fileinto "Test";
}

Vacation Sieve Out Of Office Plugin for Mozilla Thunderbird

Massive Example of Sieve - https://gist.github.com/GregBowyer/1926913

Sieve Store And Copy Messages

require "vacation";
if header :contains "From" "me@otherdomain.com" {
    stop;
}
if header :contains "To" [ "me@mydomain.com" ] {
    redirect "me@otherdomain.com";
    keep;
}

NEW VERSION

https://github.com/opensolutions/sieve-out-of-office

    Sieve Settings
      Server Name: 192.168.0.207
             Port: 4190
   Authentication: Use login from IMAP Account
        User Name: test@domain.org.uk
Secure Connection: false

OLD VERSION

http://adullact.net/plugins/mediawiki/wiki/milimail/index.php/Out_of_Office

    Sieve Settings
      Server Name: 192.168.0.207
             Port: 4190
   Authentication: Use login from IMAP Account
        User Name: test@domain.org.uk
Secure Connection: false

Just create a ~/.procmailrc file in your user's home directory...

DEFAULT=$HOME/.maildir/
LOGFILE=$HOME/procmail.log
DELIVER="/usr/libexec/dovecot/deliver"
DROPPRIVS="YES"
:0 w
| $DELIVER

...and then check the server email logs for the entry...

dovecot: lda(sieve): sieve: msgid=<201307151456.r6FEusZI017531@mail.server.com>: sent vacation response to <me@server.com>

Or, a global /etc/procmailrc for the whole server...

# Use maildir-style mailbox in user's home directory
DEFAULT=$HOME/.maildir/
# Log actions to file
LOGFILE=$HOME/procmail.log
# Log synopsis of messages
LOGABSTRACT=all
# Be verbose
VERBOSE=no
# Pass to Dovecot for Sieve
DELIVER="/usr/libexec/dovecot/deliver"
DROPPRIVS="YES"
:0 w
| $DELIVER