大网数据广告活动
服务器运维问答

Change location of maildir

· 52CE 我爱测

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, …

问题原文

原帖链接 · usr-local-ΕΨΗΕΛΩΝ · CC BY-SA 3.0

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 omitted].

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.

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-10-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。