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 user@example.com.

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.

  • 1
    Possible solution: soft-linking /var/spool/mail to /home/mail will hold the mail queue under /home – usr-local-ΕΨΗΕΛΩΝ Oct 27 '14 at 9:47
  • Typically dovecot is the IMAP/POP3 daemon used by the recipients to read email and neither the incoming/outgoing SMTP server, nor the local delivery agent. To change the location of the default mail dirctory you most likely need both to change where sendmail/postfix/exim or whatever you're using delivers email, as well as Dovecot's configuration. – HBruijn Oct 27 '14 at 10:26
  • 1
    @usr-local-ΕΨΗΕΛΩΝ I applied HBruijn's answer on my server and it works great. Can you please accept his answer if it answers your question? – Serrano Aug 23 '16 at 18:03
  • Sorry that I involuntarily buried it – usr-local-ΕΨΗΕΛΩΝ Aug 24 '16 at 7:49

Recommended is to use the Maildir directory format to store email rather than the 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.

Convention is to store mail in a ~/Maildir directory in a users home directory, but nothing prevents you from using another (hidden) directory.

You configure both the Maildir format as well as it's location with the postfix home_mailbox setting:

sudo postconf -e "home_mailbox = Maildir/"

Which is also the default location configured for most Dovecot packages.
The alternative is to configure postfix to leave local mail delivery to Dovecot with the Dovecot LDA or LSMTP.

Then configure Dovecot to look for mail in the correct location as well:

mail_location = maildir:~/Maildir

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.