Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| email:configure-dovecot [2025/03/03 20:27] – willy | email:configure-dovecot [2026/01/22 17:58] (current) – [Setup Sieve] willy | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Configuring Dovecot ====== | + | ====== |
| Dovecot configuation is stored in **/ | Dovecot configuation is stored in **/ | ||
| 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**: | ||
| < | < | ||
| - | protocols | + | dovecot_config_version |
| - | login_greeting | + | dovecot_storage_version = 2.4.2 |
| + | |||
| + | !include_try conf.d/ | ||
| + | |||
| + | protocols { | ||
| + | | ||
| + | lmtp = yes | ||
| + | | ||
| + | } | ||
| + | |||
| + | mail_home | ||
| + | mail_driver = maildir | ||
| + | mail_path = ~/maildir | ||
| + | |||
| + | mail_uid = vmail | ||
| + | mail_gid = vmail | ||
| + | |||
| + | namespace inbox { | ||
| + | inbox = yes | ||
| + | separator = / | ||
| + | } | ||
| + | |||
| + | sql_driver = sqlite | ||
| + | sqlite_path = / | ||
| + | |||
| + | passdb sql { | ||
| + | query = SELECT username, domain, password FROM mailbox WHERE username = ' | ||
| + | } | ||
| + | |||
| + | userdb sql { | ||
| + | query = SELECT CONCAT('/ | ||
| + | iterate_query = SELECT username AS user FROM mailbox | ||
| + | } | ||
| </ | </ | ||
| - | ===== Setup auth endpoint for postfix ===== | + | ===== Setup link to postfix ===== |
| Changes in **conf.d/ | Changes in **conf.d/ | ||
| < | < | ||
| + | service lmtp { | ||
| + | unix_listener / | ||
| + | group = postfix | ||
| + | mode = 0660 | ||
| + | user = postfix | ||
| + | } | ||
| + | |||
| service auth { | service auth { | ||
| unix_listener / | unix_listener / | ||
| Line 28: | Line 69: | ||
| </ | </ | ||
| - | ===== Setup authentication | + | This is required because postfix will use dovecot to deliver mail to mailboxes internally and to perform SASL authentication |
| - | Changes in **conf.d/10-auth.conf**: | + | ===== Setup Sieve ===== |
| + | |||
| + | Sieve let's you create custom filters that will filter your inbound emails. | ||
| + | |||
| + | Changes in **conf.d/90-sieve.conf**: | ||
| < | < | ||
| - | auth_mechanisms = plain login | + | sieve_script personal { |
| - | # | + | |
| - | # | + | } |
| - | #!include auth-system.conf.ext | + | |
| - | !include auth-sql.conf.ext | + | |
| </ | </ | ||
| - | ===== Setup SQL backend ===== | + | And enable sieve for lmtp (local delivery), edit **conf.d/ |
| + | < | ||
| + | protocol lmtp { | ||
| + | mail_plugins { | ||
| + | sieve = yes | ||
| + | } | ||
| + | </ | ||
| - | Changes in **dovecot-sql.conf.ext**: | + | |
| + | ===== Setup authentication ===== | ||
| + | |||
| + | Changes in **conf.d/10-auth.conf**: | ||
| < | < | ||
| - | driver | + | auth_mechanisms |
| - | connect = / | + | |
| - | password_query = SELECT username, domain, password FROM mailbox WHERE username = ' | + | |
| - | user_query = SELECT CONCAT('/ | + | |
| - | iterate_query = SELECT username AS user FROM mailbox | + | |
| </ | </ | ||
| Line 54: | Line 102: | ||
| Changes in **conf.d/ | Changes in **conf.d/ | ||
| < | < | ||
| - | mail_location | + | mail_home |
| - | mail_uid = 5000 | + | mail_driver = maildir |
| - | mail_gid = 5000 | + | mail_path = ~/maildir |
| + | |||
| + | mail_uid = vmail | ||
| + | mail_gid = vmail | ||
| </ | </ | ||
| Line 65: | Line 116: | ||
| Changes in **conf.d/ | Changes in **conf.d/ | ||
| < | < | ||
| - | ssl_cert | + | ssl = yes |
| - | ssl_key | + | ssl_server { |
| + | cert_file | ||
| + | | ||
| + | } | ||
| </ | </ | ||
| - | ===== 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 **/ |
| + | <file - dovecot.sh> | ||
| + | cp / | ||
| + | cp / | ||
| + | chmod o+r / | ||
| + | / | ||
| + | </ | ||
| - | TBD | + | the chmod is required for command line tools using **doveadm**, |
| - | < | + | ===== Testing ===== |
| - | # Sieve | + | |
| - | managesieve_notify_capability = mailto | + | Start dovecot |
| - | managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i; | + | |
| + | Check that login works: | ||
| + | < | ||
| + | doveadm auth test -a / | ||
| </ | </ | ||
| + | Test IMAP: | ||
| + | <code bash> | ||
| + | telnet mail.mydomain.com 143 | ||
| + | Trying 1.2.3.4... | ||
| + | Connected to mail.mydomain.com. | ||
| + | Escape character is ' | ||
| + | * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] IMAP </ | ||
| + | |||
| + | Test that login works: | ||
| + | <code bash> | ||
| + | telnet 127.0.0.1 1143 | ||
| + | Trying 127.0.0.1... | ||
| + | Connected to 127.0.0.1. | ||
| + | Escape character is ' | ||
| + | * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] IMAP server ready. | ||
| + | a login user@mydomain.com password | ||
| + | a OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY SPECIAL-USE] Logged in | ||
| + | </ | ||
| + | |||
| + | Test TLS works: | ||
| + | <code bash> | ||
| + | openssl s_client -connect mail.mydomain.com: | ||
| + | [ expect similar output as above ] | ||
| + | </ | ||
| + | |||
| + | Test STARTTLS works: | ||
| + | <code bash> | ||
| + | openssl s_client -connect mail.mydomain.com: | ||
| + | [ expect similar output as above ] | ||
| + | </ | ||
| + | If all those checks worked fine, your dovecot seems all set! | ||