把Dovecot设置成一个imap或者pop3服务器
设置
To configure dovecot, you edit the file /etc/dovecot/dovecot.conf. There are a couple of choices which you need to make.
欲设置dovecot。你需要编辑/etc/dovecot/dovecot.conf文件。你需要修改几个选项。
Choice of Protocols
协议的选择
The choice is broadly between two protocols: IMAP and POP3. POP3 is useful when e-mail is checked from only one computer, and is best for people who download their email, and then work offline. IMAP is the better choice when you would like to check your mail from multiple computers, at work and home, for example. IMAP has the added benefit of accessing folders on the server, allowing you to organize your e-mail, and access it from anywhere. For more information, see the wikipedia articles on POP3 and IMAP.
协 议的选择主要有两种:IMAP和POP3。当只在一台电脑上查看邮件时,POP3协议是很有用的,对于那些先下载邮件,再脱机处理邮件的人来说,POP3 协议是最好的。如果你想从多台电脑上查看你的邮件,例如:在家用的电脑和在办公室用的电脑上查看你的邮件,IMAP是更好的选择。IMAP有个额外的好 处,允许你访问服务器上的文件夹,允许你识别你的邮件和从任何一个地方访问它。想得到相关的更多信息。请看POP3 和IMAP里的wikipedia部分。
IMAPS and POP3S are more secure that the simple IMAP and POP3 because they use SSL encryption to connect.
IMAPS和POP3S比普通的IMAP和POP3更加安全,因为他们在连接时使用了加密套接字协议层来加密。
Once you have chosen, amend the following line in the file /etc/dovecot/dovecot.conf:
一旦你决定了选择哪些协议,修改配置文件/etc/dovecot/dovecot.conf中的以下行:
protocols = pop3 pop3s imap imaps
This enables those protocols when dovecot is started. Note: if you like, you can enable all the above protocols, but if you prefer, simply enable one or more of them. In addition, add the following line in pop3 section in the /etc/dovecot/dovecot.conf::
当dovecot服务启动时,这些协议将生效。注意:如果你愿意,你可以使上面列举出的协议都生效,但如果你有所选择,就只需要使其中的一个或几个生效。另外,请把下面这行添加到/etc/dovecot/dovecot.conf文件中的pop3部分中。
pop3_uidl_format = %08Xu%08Xv
Choice of Mailboxes
邮箱的选择
Dovecot currently supports maildir and mbox formats. They are the most commonly used mailbox formats. They both have their own benefits, discussed here.
Dovecot目前支持maildir和mbox两种形式。它们是常用的邮箱形式。它们各有各的好处,请在这里讨论here。
If you have trouble figuring out what you are using, it's most likely mbox. Maildir mails are almost always stored in ~/Maildir/ directory,which contains cur/, new/ and tmp/ subdirectories. In maildir each mail is stored in a separate file, while with the mbox format one file contains all mails in the mailbox. Files in /var/mail/ are nearly always mbox files, one for each user.
如 果你不知道你用的哪种形式的邮箱,一般情况下都是mbox。Maildir邮件大多数都存储在~/Maildir/目录,这个目录包含了cur/, new/ and tmp/子目录。maildir中,每封邮件都存放在一个单独的文件里。而mbox形式的邮箱,一个文件包括了邮箱里的所有邮件。/var/mail/里 的文件几乎都是mbox文件,每个用户一个文件。
If you have trouble figuring out what you should be using, choose maildir. It's overall more scalable and it can't get corrupted.
如果你不知道你该使用哪种形式的邮箱,请选择maildir。它可以全面升级,并且不容易被破坏。
You configure dovecot to use your chosen mailbox, you need to edit the file /etc/dovecot/dovecot.conf}. Amend the following line:
你设置dovecot来使用你选择的邮箱形式,你需要编辑/etc/dovecot/dovecot.conf文件。修改以下行:
default_mail_env = maildir:~/Maildir (for maildir)
or
default_mail_env = mbox:~/mail:INBOX=/var/mail/%u (for mbox)
Note: You will also need to configure your MTA to transfer the incoming mail to this type of mailbox. (If you installed Postfix with instructions from the previous wiki, then chose mbox.)
注意:你同时也需要设置你的邮件传输代理来把接收到的邮件转化成这种邮箱的形式。(如果你按照previous wiki中 的说明安装了Postfix,请选择mbox) Setting up Maildir设置Maildir . Do these steps ONLY if you want Maildir. This setup will put the Maildir in each user's home directory.
如果你只想设置Maildir,需要做这几步。本设置把Maildir放在每个用户的宿主目录下。
If you a using Postfix MTA, edit /etc/postfix/main.cd:
如果你正在使用Postfix做邮件传输代理,请编辑/etc/postfix/main.cd文件
home_mailbox = Maildir/
# mailbox_command = procmail -a "$EXTENSION"
Edit /etc/dovecot/dovecot.conf:
编辑/etc/dovecot/dovecot.conf
default_mail_env = maildir:/home/%u/Maildir
It's a good idea to pre-create the Maildir for future users:
为将来的用户提前创建Maildir是个不错的主意
maildirmake.dovecot /etc/skel/Maildir
maildirmake.dovecot /etc/skel/Maildir/.Drafts
maildirmake.dovecot /etc/skel/Maildir/.Sent
maildirmake.dovecot /etc/skel/Maildir/.Trash
maildirmake.dovecot /etc/skel/Maildir/.Templates
Then, for an existent user:
接着为已存在的用户创建Maildir
cp -r /etc/skel/Maildir /home/myuser/
chown -R myuser:usergroup /home/myuser/Maildir
chmod -R 700 /home/myuser/Maildir
Test
测试
Start dovecot:
启动dovecot
/etc/init.d/dovecot start
To check that it is running, type the command ps -A|grep dovecot. You should see the dovecot service running. If you have enabled imap, or pop3, you can also try to log in with the commands telnet localhost pop3 or telnet localhost imap2. If you see something like the following, the installation has been successful.
要检查dovecot是否运行,请键入ps -A|grep dovecot命令。你应该会看到dovecot服务正在运行。如果你已经使imap或者pop3协议生效,你也可以试着键入telnet localhost pop3 或者 telnet localhost imap2 命令登陆。如果你看到以下几行出现在屏幕上,安装就是正确的了。
matt@kalliope:~$ telnet localhost pop3
Trying localhost...
Connected to localhost.
Escape character is '^]'.
+OK dovecot ready.
Authentication
认证
If you've got this far, dovecot is working but you have to send it your password in plain text in order to login. If you are using imaps or pop3s, this is not a problem, because the transfer is done via an encrypted connection. If you are using simply imap or pop3, and will be connecting to the server from outside your local computer or home network, it is a good idea to configure more secure authentication. For further details about how to do this, see this page on the dovecot website.
如 果你使用认证,dovecot会工作,但你必须把你的密码保存到文本文档里,并把密码发送给服务器用来登陆。如果你正在使用imaps或者pop3s 协议,将不会有任何问题,因为传输是通过加密连接完成的。如果你正在使用不加密的imap或者pop3协议,并且你打算从本地的电脑或者本地网络 以外的地方连接服务器,设置更加安全的认证是一个好办法。关于怎么样设置认证的详细情况请参考dovecot网站的这一页 this page。
SSL
加密
To configure dovecot to use SSL, edit the file /etc/dovecot/dovecot.conf and amend the following lines (in some cases you may simply have to remove the # symbol from the beginning of the line):
欲设置使用SSL的dovecot,请编辑/etc/dovecot/dovecot文件,修改以下几行(在某些情况下,你只需要去掉以下几行开头的注释即可)
ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem
ssl_disable = no
disable_plaintext_auth = no.
The cert and key files are created automatically by dovecot when you install it. Please note, that these keys are not signed and will give "bad signature" errors when connecting from a client. To avoid this, you can use commercial certificates, or even better, you can use your own SSL certificates. Hopefully, a guide will appear soon on this wiki on how to do this. In the meantime, here are some good ones: this guide on the Linux howto database, and this guide on the Debian Administration website.
加 密的证书和密钥文件会在dovecot安装时自动创建。请注意,这些密钥还没有被签署,因此,当客户端连接时,服务器会报一个“失败的签名”的错误。为了 避免此错误,你可以使用商业证书,除此之外,更好的方法是你可以使用你自己的加密证书。希望关于怎么样使用以上方法的指南尽快出现在Wiki里。同时,这 里有一些好的例子:linux数据库指南this guide和Debian管理网站上的指南this guide。
Accessing from Outside
从外界访问
In order to access your mail server from another computer, you'll have to configure your firewall or router to allow connections to the server on the necessary ports:
为了使其他电脑能够访问你的邮件服务器,你需要设置你的防火墙或者路由,以便允许以下必要的断口连接服务器。
- IMAP - 143
- IMAPS - 993
- POP3 - 110
- POP3S - 995
Email Clients
邮件客户端
Thunderbird
雷鸟
To use with Thunderbird, edit the file /etc/dovecot/dovecot.conf:
欲使用雷鸟,需要编辑 /etc/dovecot/dovecot.conf中的以下几行
protocol imap {
...
login_greeting_capability = yes
imap_client_workarounds = tb-extra-mailbox-sep
}
In Thunderbird, under Server Settings -> Advanced, uncheck "Show only subscribed folders".
在雷鸟设置界面的服务器设置->高级选项中,不选中“只显示预定的文件夹”即可。to "把Dovecot设置成一个imap或者pop3服务器"
Linux下Sendmail邮件服务器的配置详解 (2007-3-16 16:4:14)
杂七杂八的教程 (2007-1-21 14:27:52)
赞助商