Dovecot/Installation: Unterschied zwischen den Versionen
Die Seite wurde neu angelegt: „== Installation == === Dovecot === Dovecot is a POP3 and IMAP server, which provides email clients with access to emails on the server. * It also acts as the ''Local Delivery Agent'' (LDA), which takes email from Postfix (or other MTA / mail server software) and stores them. When Dovecot was installed in previous steps, additional Dovecot modules (including dovecot-antispam, dovecot-solr, dovecot-ldap, and dovecot-sieve) were also installed. * These mo…“ |
K Textersetzung - „ Postfix “ durch „ Postfix “ |
||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| Zeile 2: | Zeile 2: | ||
=== Dovecot === | === Dovecot === | ||
Dovecot is a POP3 and IMAP server, which provides email clients with access to emails on the server. | Dovecot is a POP3 and IMAP server, which provides email clients with access to emails on the server. | ||
* It also acts as the ''Local Delivery Agent'' (LDA), which takes email from Postfix (or other MTA / mail server software) and stores them. | * It also acts as the ''Local Delivery Agent'' (LDA), which takes email from [[Postfix]] (or other MTA / mail server software) and stores them. | ||
When Dovecot was installed in previous steps, additional Dovecot modules (including dovecot-antispam, dovecot-solr, dovecot-ldap, and dovecot-sieve) were also installed. | When Dovecot was installed in previous steps, additional Dovecot modules (including dovecot-antispam, dovecot-solr, dovecot-ldap, and dovecot-sieve) were also installed. | ||
| Zeile 252: | Zeile 252: | ||
# Restart Dovecot to enable all configurations: | # Restart Dovecot to enable all configurations: | ||
# systemctl restart dovecot | # systemctl restart dovecot | ||
[[Kategorie:Dovecot]] | |||
Aktuelle Version vom 4. Juli 2026, 13:09 Uhr
Installation
Dovecot
Dovecot is a POP3 and IMAP server, which provides email clients with access to emails on the server.
- It also acts as the Local Delivery Agent (LDA), which takes email from Postfix (or other MTA / mail server software) and stores them.
When Dovecot was installed in previous steps, additional Dovecot modules (including dovecot-antispam, dovecot-solr, dovecot-ldap, and dovecot-sieve) were also installed.
- These modules help Dovecot with a range of functions like spam filtering, user directory management, enabling a full text search, and mail filtering.
Configuring Dovecot
- edit configuration files to use IMAP (and POP3)
- add our domain details
- configure user authentication
- force users to use SSL
- when they connect so that their passwords are never sent to the server in plain text
- Copy all of the configuration files so you can easily revert back to them if needed
# cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig # cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.orig # cp /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.orig # cp /etc/dovecot/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext.orig # cp /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.orig # cp /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.orig
- Edit the /etc/dovecot/dovecot.conf file.
- Add protocols = imap pop3 lmtp to the
- Enable installed protocols section of the file
- In addition, add the line post_master_address = postmaster at example.com, replacing example.com with your domain
File: /etc/dovecot/dovecot.conf
## Dovecot configuration file ... # Enable installed protocols !include_try /usr/share/dovecot/protocols.d/*.protocol protocols = imap pop3 lmtp postmaster_address = postmaster at example.com [...]
- Edit the /etc/dovecot/conf.d/10-mail.conf
This file controls how Dovecot interacts with the server’s file system to store and retrieve messages.
- Modify the following variables within the configuration file:
- /etc/dovecot/conf.d/10-mail.conf
[...] mail_location = maildir:/var/mail/vhosts/%d/%n/ [...] mail_privileged_group = mail
- Create the /var/mail/vhosts/ directory
and a subdirectory for your domain, replacing example.com with your domain name
# mkdir -p /var/mail/vhosts/example.com
This directory will serve as storage for mail sent to your domain.
- Create the vmail group with ID 5000.
- Add a new user vmail to the vmail group.
- This system user will read mail from the server.
# groupadd -g 5000 vmail # useradd -g vmail -u 5000 vmail -d /var/mail
Change the owner of the /var/mail/ folder and its contents to belong to vmail:
# chown -R vmail:vmail /var/mail
- Edit the user authentication file, located in /etc/dovecot/conf.d/10-auth.conf.
- Uncomment the following variables and replace with the file excerpt’s example values:
- /etc/dovecot/conf.d/10-auth.conf
[...] disable_plaintext_auth = yes [...] auth_mechanisms = plain login [...] !include auth-system.conf.ext [...] !include auth-sql.conf.ext
Note For reference, view a complete 10-auth.conffile.* Edit the /etc/dovecot/conf.d/auth-sql.conf.ext file with authentication and storage information.
- Ensure your file contains the following lines.
- Make sure the passdb section is uncommented, that the userdb section that uses the static driver is uncommented and updated with the right argument.
- Then comment out the userdb section that uses the sql driver:
- File: /etc/dovecot/conf.d/auth-sql.conf.ext
| ...
passdb { driver = sql args = /etc/dovecot/dovecot-sql.conf.ext } ... #userdb {
# driver = sql
# args = /etc/dovecot/dovecot-sql.conf.ext
#}
... userdb { driver = static args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n } ... |
- Update the /etc/dovecot/dovecot-sql.conf.ext file with your MySQL connection information.
- Uncomment the following variables and replace the values with the excerpt example.
- Replace dbname, user and password with your own MySQL database values:
- File: /etc/dovecot/dovecot-sql.conf.ext
| ...
driver = mysql ... connect = host=127.0.0.1 dbname=mailserver user=mailuser password=mailuserpass ... default_pass_scheme = SHA512-CRYPT ... password_query = SELECT email as user, password FROM virtual_users WHERE email='%u'; ... |
The password_query variable uses email addresses listed in the virtual_users table as the username credential for an email account.
To use an alias as the username:# Add the alias as the source and destination email address to the virtual_aliases table.
- Change the /etc/dovecot/dovecot-sql.conf.ext file’s password_query value to password_query = SELECT email as user, password FROM virtual_users WHERE email=(SELECT destination FROM virtual_aliases WHERE source = '%u');
Note
For reference, view a complete dovecot-sql.conf.extfile.* Change the owner and group of the /etc/dovecot/ directory to vmail and dovecot:
# chown -R vmail:dovecot /etc/dovecot* Change the permissions on the /etc/dovecot/ directory to be recursively read, write, and execute for the owner of the directory:
# chmod -R o-rwx /etc/dovecot* Edit the service settings file /etc/dovecot/conf.d/10-master.conf:
Note
When editing the file, be careful not to remove any opening or closing curly braces.
- If there’s a syntax error, Dovecot will crash silently.
- You can check /var/log/upstart/dovecot.log to debug the error.
Here is an example of a complete 10-master.conf file.
Disable unencrypted IMAP and POP3 by setting the protocols' ports to 0.
- Uncomment the port and ssl variables:
File: /etc/dovecot/conf.d/10-master.conf
| ...
service imap-login { inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
...
} ... service pop3-login { inet_listener pop3 {
port = 0
}
inet_listener pop3s {
port = 995
ssl = yes
}
} ... |
Find the service lmtp section of the file and use the configuration shown below:
File: /etc/dovecot/conf.d/10-master.conf
| ...
service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp {
#mode = 0666i
mode = 0600
user = postfix
group = postfix
}
... } |
Locate service auth and configure it as shown below:
File: /etc/dovecot/conf.d/10-master.conf
| ...
service auth { ...
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
... user = dovecot } ... |
In the service auth-worker section, uncomment the user line and set it to vmail:* File: /etc/dovecot/conf.d/10-master.conf
| ...
service auth-worker { ... user = vmail } |
Save the changes to the /etc/dovecot/conf.d/10-master.conf file.* Edit /etc/dovecot/conf.d/10-ssl.conf file to require SSL and to add the location of your domain’s SSL certificate and key.
- Replace example.com with your domain:
- File: /etc/dovecot/conf.d/10-ssl.conf
...
# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt> ssl = required ... ssl_cert = </etc/letsencrypt/live/example.com/fullchain.pem ssl_key = </etc/letsencrypt/live/example.com/privkey.pem |
- Restart Dovecot to enable all configurations:
# systemctl restart dovecot