User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
email:configure-dovecot [2025/03/13 14:05] – [Configuring Dovecot] willyemail:configure-dovecot [2026/01/22 17:58] (current) – [Setup Sieve] willy
Line 4: Line 4:
  
 For each file, i will show you the changes from the defaults that you need to apply. For each file, i will show you the changes from the defaults that you need to apply.
 +
 +**NOTE:** Dovecot 2.4 introduced some changes to the config file. The following has been adapted to this new format.
  
 ===== Main changes ===== ===== Main changes =====
Line 11: Line 13:
 Edit **doveconf.conf**: Edit **doveconf.conf**:
 <code> <code>
-protocols imap lmtp sieve +dovecot_config_version 2.4.2 
-login_greeting IMAP server ready+dovecot_storage_version 2.4.2 
-# Optional DEBUG stuff to enable if things don't work: + 
-#auth_verbose = yes +!include_try conf.d/*.conf 
-#auth_verbose_passwords no + 
-#auth_debug = yes +protocols { 
-#auth_debug_passwords yes +  imap = yes 
-#mail_debug yes +  lmtp yes 
-#verbose_ssl = yes+  sieve = yes 
 +
 + 
 +mail_home /home/vmail/storage/%{user | domain}/%{user | username} 
 +mail_driver maildir 
 +mail_path = ~/maildir 
 + 
 +mail_uid = vmail 
 +mail_gid = vmail 
 + 
 +namespace inbox { 
 +  inbox = yes 
 +  separator = / 
 +
 + 
 +sql_driver = sqlite 
 +sqlite_path = /home/vmail/database/vmail.sqlite3 
 + 
 +passdb sql { 
 +  query = SELECT username, domain, password FROM mailbox WHERE username = '%{user}' AND active = 1 
 +
 + 
 +userdb sql { 
 +  query = SELECT CONCAT('/home/vmail/storage/', maildir) AS home, CONCAT('maildir:storage=', quota) AS quota FROM mailbox WHERE username = '%{user}' AND active = 1 
 +  iterate_query = SELECT username AS user FROM mailbox 
 +}
 </code> </code>
  
Line 48: Line 75:
 Sieve let's you create custom filters that will filter your inbound emails. Sieve let's you create custom filters that will filter your inbound emails.
  
-Changes in **conf.d/20-lmtp.conf**:+Changes in **conf.d/90-sieve.conf**:
 <code> <code>
-protocol lmtp +sieve_script personal 
-  mail_plugins $mail_plugins sieve+  path /home/vmail/storage/%{user | domain}/%{user | username}/sieve
 } }
 </code> </code>
  
-And specify which folder should store the filters. +And enable sieve for lmtp (local delivery), edit **conf.d/20-lmtp.conf**:
- +
-Changes in **conf.d/90-sieve.conf**:+
 <code> <code>
-plugin +protocol lmtp 
-  sieve = file:/home/vmail/storage/%d/%n/sieve;active=/home/vmail/storage/%d/%n/.dovecot.sieve+    mail_plugins { 
 +    sieve = yes 
 +  }
 </code> </code>
 +
  
 ===== Setup authentication ===== ===== Setup authentication =====
Line 68: Line 96:
 <code> <code>
 auth_mechanisms = plain login auth_mechanisms = plain login
-#auth_default_realm = mydomain.com # is this needed? 
-#auth_realms = mydomain.com # is this needed? 
-#!include auth-system.conf.ext 
-!include auth-sql.conf.ext 
-</code> 
- 
-===== Setup SQL backend ===== 
- 
-Changes in **dovecot-sql.conf.ext**: 
-<code> 
-driver = sqlite 
-connect = /home/vmail/database/vmail.sqlite3 
-password_query = SELECT username, domain, password FROM mailbox WHERE username = '%u' AND active = 1 
-user_query = SELECT CONCAT('/home/vmail/storage/', maildir) AS home, CONCAT('maildir:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = 1 
-iterate_query = SELECT username AS user FROM mailbox 
 </code> </code>
  
Line 89: Line 102:
 Changes in **conf.d/10-mail.conf**: Changes in **conf.d/10-mail.conf**:
 <code> <code>
-mail_location maildir:/home/vmail/storage/%d/%n/maildir +mail_home = /home/vmail/storage/%{user | domain}/%{user | username} 
-mail_uid = 5000 +mail_driver = maildir 
-mail_gid = 5000+mail_path = ~/maildir 
 + 
 +mail_uid = vmail 
 +mail_gid = vmail
 </code> </code>
  
Line 100: Line 116:
 Changes in **conf.d/10-ssl.conf**: Changes in **conf.d/10-ssl.conf**:
 <code> <code>
-ssl_cert </etc/letsencrypt/live/mail.mydomain.com/fullchain.pem +ssl = yes 
-ssl_key </etc/letsencrypt/live/mail.mydomain.com/privkey.pem+ssl_server { 
 +  cert_file = /etc/dovecot/fullchain.pem 
 +  key_file = /etc/dovecot/privkey.pem 
 +}
 </code> </code>
  
-===== Setup Sieve and ManageSieve ===== +For this to work, you need to ensure that the certs are properly moved after being renewed by Let's Encrypt. I use the following post hook in **/etc/letsencrypt/renewal-hooks/post/dovecot.sh**: 
- +<file - dovecot.sh
-TBD +cp /etc/letsencrypt/live/[cert path]/privkey.pem /etc/dovecot/privkey.pem 
- +cp /etc/letsencrypt/live/[cert path]/fullchain.pem /etc/dovecot/fullchain.pem 
-<code+chmod o+r /etc/dovecot/privkey.pem /etc/dovecot/fullchain.pem 
-# Sieve +/etc/init.d/dovecot restart 
-managesieve_notify_capability = mailto +</file>
-managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date +
-</code>+
  
 +the chmod is required for command line tools using **doveadm**, like PostfixAdmin.
  
 ===== Testing ===== ===== Testing =====