Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
email:configure-dovecot [2025/03/03 14:34] – created willy | email:configure-dovecot [2025/03/13 14:05] (current) – [Configuring Dovecot] willy | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Configuring Dovecot ====== | + | ====== |
+ | Dovecot configuation is stored in **/ | ||
- | <file - dovecot.conf> | + | For each file, i will show you the changes from the defaults that you need to apply. |
- | log_path = syslog | + | |
- | syslog_facility = mail | + | |
- | mail_debug = no | + | |
- | auth_debug = no | + | |
- | auth_debug_passwords = no | + | |
- | auth_verbose = no | + | |
- | base_dir = / | + | |
- | listen = * | + | |
- | protocols = imap sieve | + | |
- | login_greeting = IMAPD ready. | + | |
- | # Mailbox setup | + | ===== Main changes ===== |
- | mail_location | + | |
- | namespace inbox { | + | |
- | inbox = yes | + | |
- | } | + | |
- | mail_uid | + | |
- | mail_gid | + | |
- | mailbox_list_index | + | |
- | mailbox_idle_check_interval | + | |
- | maildir_copy_with_hardlinks | + | |
- | # Sieve | + | You need to enable the selected protocols and change the login greeting, as i don't like to let others know that i use dovecot, for security reasons. |
- | managesieve_notify_capability = mailto | + | |
- | managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i; | + | |
- | # Authentication and login | + | Edit **doveconf.conf**: |
- | disable_plaintext_auth | + | < |
- | auth_default_realm | + | protocols = imap lmtp sieve |
- | auth_mechanisms | + | login_greeting = IMAP server ready. |
- | auth_realms | + | # Optional DEBUG stuff to enable if things don't work: |
- | auth_failure_delay | + | # |
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | </ | ||
- | # SQLite | + | ===== Setup link to postfix |
- | sql_driver | + | |
- | sqlite_path | + | Changes in **conf.d/ |
- | passdb sql { | + | < |
- | query = SELECT username, domain, password FROM mailbox WHERE username | + | service lmtp { |
- | } | + | |
- | userdb sql { | + | group = postfix |
- | | + | |
- | | + | |
- | } | + | } |
service auth { | service auth { | ||
Line 54: | Line 40: | ||
} | } | ||
} | } | ||
+ | </ | ||
- | # SSL TLS setup | + | This is required because postfix will use dovecot to deliver mail to mailboxes internally and to perform SASL authentication as well. |
- | ssl = yes | + | |
+ | ===== Setup Sieve ===== | ||
+ | |||
+ | Sieve let's you create custom filters that will filter your inbound emails. | ||
+ | |||
+ | Changes in **conf.d/ | ||
+ | < | ||
+ | protocol lmtp { | ||
+ | mail_plugins = $mail_plugins sieve | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | And specify which folder should store the filters. | ||
+ | |||
+ | Changes in **conf.d/ | ||
+ | < | ||
+ | plugin { | ||
+ | sieve = file:/ | ||
+ | </ | ||
+ | |||
+ | ===== Setup authentication ===== | ||
+ | |||
+ | Changes in **conf.d/ | ||
+ | < | ||
+ | auth_mechanisms = plain login | ||
+ | #auth_default_realm = mydomain.com # is this needed? | ||
+ | # | ||
+ | #!include auth-system.conf.ext | ||
+ | !include auth-sql.conf.ext | ||
+ | </ | ||
+ | |||
+ | ===== Setup SQL backend ===== | ||
+ | |||
+ | Changes in **dovecot-sql.conf.ext**: | ||
+ | < | ||
+ | driver = sqlite | ||
+ | connect = / | ||
+ | password_query = SELECT username, domain, password FROM mailbox WHERE username = ' | ||
+ | user_query = SELECT CONCAT('/ | ||
+ | iterate_query = SELECT username AS user FROM mailbox | ||
+ | </ | ||
+ | |||
+ | ===== Setup mailboxes ===== | ||
+ | |||
+ | Changes in **conf.d/ | ||
+ | < | ||
+ | mail_location = maildir:/ | ||
+ | mail_uid = 5000 | ||
+ | mail_gid = 5000 | ||
+ | </ | ||
+ | |||
+ | ===== Setup TLS ===== | ||
+ | |||
+ | You need to point to the Let's Encrypt certificates. | ||
+ | |||
+ | Changes in **conf.d/ | ||
+ | < | ||
ssl_cert = </ | ssl_cert = </ | ||
ssl_key = </ | ssl_key = </ | ||
- | ssl_min_protocol | + | </ |
- | ssl_cipher_list | + | |
+ | ===== Setup Sieve and ManageSieve ===== | ||
+ | |||
+ | TBD | ||
+ | |||
+ | < | ||
+ | # Sieve | ||
+ | managesieve_notify_capability = mailto | ||
+ | managesieve_sieve_capability | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Testing ===== | ||
+ | |||
+ | Start dovecot | ||
+ | |||
+ | Check that login works: | ||
+ | <code bash> | ||
+ | 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 | ||
+ | </ | ||
- | </file> | + | Test TLS works: |
+ | <code bash> | ||
+ | openssl s_client -connect mail.mydomain.com: | ||
+ | [ expect similar output as above ] | ||
+ | </code> | ||
+ | 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! | ||