Dovecot & Getmail

Installation

aptitude install dovecot-imapd dovecot-sieve getmail4

Configuration

Overwriting predefined values via /etc/dovecot/local.conf:

# SSL configuration
ssl = required
ssl_cert = </etc/letsencrypt/live/domain.example/cert.pem
ssl_key = </etc/letsencrypt/live/domain.example/privkey.pem

# Where to put received mail
mail_location=maildir:~/Maildir

# Enable zlib plugin globally for reading/writing
mail_plugins = $mail_plugins zlib

# Enable compression while saving
plugin {
  zlib_save_level = 9
  zlib_save = xz
}

# Enable sieve filtering for local delivery agent
protocol lda {
  mail_plugins = $mail_plugins sieve
}

# Restrict plain imap protocol
service imap-login {
  inet_listener imap {
    address = 127.0.0.1 #Listen only on loopback
    #port = 0 #This disables it completely
  }
}

# Fix stats-writer issue for Debian 10 (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903161)
service stats {
  unix_listener stats-writer {
    mode = 0666
  }
}

User defined filtering can be achieved via ~/.dovecot.sieve files.

Getmail configurations need the following destination section to forward mails to dovecot:

[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver

Collecting mails regularly can be done via cron:

@hourly getmails -q