Standard Linux installation provide a maildir in /var/spool/mail/$user
(that's actually a single file holding all emails, not a "mail directory"), soft-linked by /var/mail/
.
I'm going to set up managed email on my installation, and I want to store mail in a separate partition that can be attached to the file system in case of server reimage (I already enforced this disaster-recovery measure for services such as mysql
). The separate filesystem is /home
.
So I would like system mail to be delivered to /home/$user/.mail[/]
(final /
in brackets because I'm not sure whether to include mail in a directory or not).
Currently, I run email for my own domain by redirecting all email to my ISP's email, which will not be forever (in case I change ISP I must migrate all email to the new ISP), so Postfix is instructed to redirect everyting directed to *@example.org
to [email protected]
.
I was thinking about using Dovecot
as email server, as it fully supports SSL.
So first, before configuring Dovecot, how do I tell the system to deliver mail in a different directory than /var/spool? Please mind that cron regularly sends email to root
when jobs don't write to /dev/null
, so the configuration must be system-wide.
It is recommended to use the Maildir directory format to store email rather than the older mbox format. The Maildir format is well supported by Dovecot and has some advantages (no locking, allows for easy incremental back-ups and restoring of individual messages.) So you’ll need to assign a directory.
It is convention to store mail in a
~/Maildir
directory in a user’s home directory, but nothing prevents you from using another (hidden) directory.You configure both the Maildir format as well as its location with the Postfix home_mailbox setting:
This is also the default location configured for most Dovecot packages.
The alternative is to configure Postfix to leave local mail delivery to the Dovecot LDA or LMTP.
Then configure Dovecot to look for mail in the correct location as well:
In case of mail users actually having local user accounts (instead of only existing as virtual mail users), you may want to populate
/etc/skell
with a Maildir and a welcome message for new users.