5

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.

4
  • 1
    Possible solution: soft-linking /var/spool/mail to /home/mail will hold the mail queue under /home Oct 27, 2014 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, 2014 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, 2016 at 18:03
  • Sorry that I involuntarily buried it Aug 24, 2016 at 7:49

1 Answer 1

9

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:

sudo postconf -e "home_mailbox = Maildir/"

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:

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .