Mail server_Dovecot storage configuration - SomethingWithHorizons/mailserver GitHub Wiki
Configure how dovecot will store the received e-mails.
Procedure
-
Create user, group and a corresponding homedir to have an entity that can write to the file system:
useradd --create-home --uid 5000 --home-dir /var/vmail vmail -
Edit
/etc/dovecot/conf.d/10-mail.confto make Dovecot stop using the default mail storage path and use the path defined in the database instead:# See doc/wiki/Variables.txt for full list. Some examples: # # mail_location = maildir:~/Maildir # mail_location = mbox:~/mail:INBOX=/var/mail/%u # mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n # # <doc/wiki/MailLocation.txt> # - mail_location = mbox:~/mail:INBOX=/var/mail/%u + mail_location = maildir:%h/Maildir%hplaceholder to be filled with SQL data as defined in Dovecot-MySQL config. -
Edit
/etc/dovecot/conf.d/10-master.confto have it create a socket file for the user/group postfix with 660 as its user permissions (so only "postfix" can "talk to" the socket file):service lmtp { - unix_listener lmtp { - #mode = 0666 + unix_listener /var/spool/postfix/private/dovecot-lmtp { + mode = 0660 + user = postfix + group = postfix } -
Tell postfix to use dovecot-lmtp as its Local Mail Transfer Protocol (LMTP) for delivery:
postconf -e "virtual_transport=lmtp:unix:private/dovecot-lmtp" -
Have your FQDN removed from '/etc/postfix/main.cf' to prevent mails to your FQDN being handled via the system delivery process, and instead use the virtual delivery process:
postconf -e 'mydestination = localhost, localhost.localdomain, localhost' -
Edit
/etc/dovecot/conf.d/15-mailboxes.confto have clients automatically optionally create, and subsequently subscribe to the standard folders in mailboxes:mailbox Drafts { + auto = subscribe special_use = \Drafts } mailbox Junk { + auto = subscribe special_use = \Junk } mailbox Trash { + auto = subscribe special_use = \Trash } # For \Sent mailboxes there are two widely used names. We'll mark both of # them as \Sent. User typically deletes one of them if duplicates are created. mailbox Sent { + auto = subscribe special_use = \Sent } -
Reload the configuration files into Dovecot and Postfix to effectuate the changes:
service dovecot reload service postfix reload