Dovecot 服务器

Dovecot 是一个主要出于安全考虑编写的邮件投递代理。它支持主要收件箱格式:mbox 或 Maidir。这部分说明如何将它设为一个 imap 或 pop3 服务器。

安装

要安装 dovecot,在命令提示符中运行下列命令:

sudo apt-get install dovecot-common dovecot-imapd dovecot-pop3d

配置

要配置 dovecot,您可以编辑文件 /etc/dovecot/dovecot.conf。您可以选择您所使用的协议。它可以是 pop3、pop3s (安全 pop3)、imap 和 imaps (安全 imap)。对这些协议的说明是超出本指南范围的。更多信息请参考 wikipedia 上关于 POP3IMAP 的文章。

IMAPS and POP3S are more secure that the simple IMAP and POP3 because they use SSL encryption to connect. Once you have chosen the protocol, amend the following line in the file /etc/dovecot/dovecot.conf:

protocols = pop3 pop3s imap imaps

It enables the protocols when dovecot is started. Next, add the following line in the pop3 section of the file /etc/dovecot/dovecot.conf:

pop3_uidl_format = %08Xu%08Xv

Next, choose the mailbox you use. Dovecot supports maildir and mbox formats. These are the most commonly used mailbox formats. They both have their own benefits and they are discussed on the dovecot website.

一旦您选择了您的收件箱格式后,就可以编辑文件 /etc/dovecot/dovecot.conf 并修改下列行:

mail_location = maildir:~/Maildir # (for maildir)
or
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox)
[注意]

您应当配置您的 MTA (Mail Transport Agent,邮件传输助理)来将新邮件传输到这类邮箱中,如果其与您已经配置的不同的话。

一旦您完成了配置 dovecot,请启动 dovecot 的守护进程以便测试您的设置:

          
            sudo /etc/init.d/dovecot start
          
        

如果您已经开启了 imap 或是 pop3,您也可以使用 telnet localhost pop3 或是 telnet localhost imap2 命令来尝试登录。如果您看到像下面这样的输出,则说明安装是成功的:

Dovecot SSL 配置

To configure dovecot to use SSL, you can edit the file /etc/dovecot/dovecot.conf and amend following lines:

ssl_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
ssl_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
ssl_disable = no
disable_plaintext_auth = no

You can get the SSL certificate from a Certificate Issuing Authority or you can create self signed SSL certificate. Please refer to “创建一个自己签署的证书”一节 for details about how to create self signed SSL certificate. Once you create the certificate, you will have a key file and a certificate file. Please copy them to the location pointed in the /etc/dovecot/dovecot.conf configuration file.

邮件服务器的防火墙配置

要从另一台计算机访问您的邮件服务器,您必须配置您的防火墙以允许连接服务器必要的端口。

  • IMAP - 143

  • IMAPS - 993

  • POP3 - 110

  • POP3S - 995