From ec99dbbcdcb533756a7962377f9a1f01814b6363 Mon Sep 17 00:00:00 2001 From: revsuine Date: Wed, 20 Nov 2024 02:59:40 +0000 Subject: [PATCH] content/blog/mail_server_alpine_postfix_dovecot_tutorial.md: add to dovecot section --- ..._server_alpine_postfix_dovecot_tutorial.md | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/content/blog/mail_server_alpine_postfix_dovecot_tutorial.md b/content/blog/mail_server_alpine_postfix_dovecot_tutorial.md index fb78926..c8afac9 100644 --- a/content/blog/mail_server_alpine_postfix_dovecot_tutorial.md +++ b/content/blog/mail_server_alpine_postfix_dovecot_tutorial.md @@ -447,7 +447,86 @@ Restart Postfix. # Dovecot -[Dovecot](https://www.dovecot.org/) is a popular IMAP and POP3 server which we'll be using for our MDA. +[Dovecot](https://www.dovecot.org/) is a popular IMAP and POP3 server which we'll be using for our MDA. Let's install +it: + + # apk add dovecot + +Check the Dovecot version with: + + $ dovecot --version + +Now let's enable IMAP by editing `/etc/dovecot/dovecot.conf`. Find a `protocols = ` line, or add one, and set it to: + +```conf +protocols = imap +``` + +## Configure how to store emails + +You probably want to use the Maildir format for storing emails, where each user's mail is stored at `~/Maildir` (this +can be set to another location if desired). + +In `/etc/dovecot/conf.d/10-mail.conf`, set: + +```conf +mail_location = maildir:~/Maildir +mail_privileged_group = mail +``` + +`mail_privileged_group` tells us which group of Unix users can send mail; in this case, it's anyone in the `mail` +group. You can create the group with: + + # addgroup mail + # adduser postfix mail + # adduser dovecot mail + +We want to ensure that `postfix` and `dovecot` users have the right to access mail. + +To change the Maildir directory, e.g. to set it to `~/mail`, you would set the following: + +`/etc/dovecot/conf.d/10-mail.conf`: + +```conf +mail_location = maildir:~/mail +``` + +`/etc/postfix/main.cf`: + +```conf +home_mailbox = mail/ +``` + +## Get emails with LMTP + +LMTP is a protocol which can be used for Postfix to pass incoming +emails to Dovecot. To install it for Dovecot: + + # apk add dovecot-lmtpd + +Add `lmtp` to the supported protocols in `/etc/dovecot/dovecot.conf`: + +```conf +protocols = imap lmtp +``` + +Now change the LMTP service (or add if it isn't already there) in `/etc/dovecot/conf.d/10-master.conf` to: + +```conf +service lmtp { + unix_listener /var/spool/postfix/private/dovecot-lmtp { + mode = 0600 + user = postfix + group = postfix + } +``` + +Postfix needs to be configured to use this socket. Edit `/etc/postfix/main.cf` with the following lines: + +```conf +mailbox_transport = lmtp:unix:private/dovecot-lmtp +smtputf8_enable = no +```