网络推荐



本广告位招租!

推荐给好友 上一篇 | 下一篇

IMAP - getting Dovecot running

BSD爱好者乐园%Xknu&}.z-Y

If you're reading this, you use email. You probably have more than one email address. I do. I have many. I run 13 domains, plus some more for friends off my two mail servers. If you're like me, you use POP to download your mail to your computer and read it there. POP works best when you use just one computer.

vjQF+S;R ?%i-f1BSD爱好者乐园Rg'j Fz ez

In this article, I will show you how I installed Dovecot and configured it so I could securely get my email. This involves setting up the certificates and configuring Dovecot.BSD爱好者乐园'Zh:kxU}

u:k)n/cH6Aq'h1IMAP can be part of a client/server email solution. In short, with IMAP your email remains on the server and you just read a copy of it with your email client. I can think of several immediate advantages with this approach (in no particular order):

0j Li$t0b;C,Hvcu @.g]1
  1. Easy backups - if all your users' email is on one server, backups are easier
  2. Change your email client - if you decide you want Pegasus, not Thunderbird, you can change that at a whim, knowing that all your email will still be available from the new client
  3. Multiple access methods - you can access your email from any IMAP client, or even via a web interface
  4. Read the same email on different systems - with me, I can be on my laptop, my desktop, the office, wherever, and I may need to have the same email at different times on different mails. IMAP solves that issue.

@B*k)l$q/FA7Yol1Those are the first reasons that come to mind. I'm sure you have your favorite reasons.
0G0U0x mPLmu;v1BSD爱好者乐园 _&i C/\H$Q#n

BSD爱好者乐园lv z4t#C7T

Before you proceed, I have some required reading for you. It is essential that you understand how email works, how it is delivered, and what IMAP can and can't do for you. Rather than create this myself, I suggest readingMailServerOverviewon theDovecot wiki.

m,C$GNvn7O nv$\1

Od(bM.X8q+]1My path to IMAP was unexpected. I had played with IMAP many months ago, but never made a decision to deploy it or not. I recently relocated to start a new job. I ran a private mail server at home which received all my email, and I POP'd the mail from there onto my Windows XP workstation. As I type this, both of those machines are stitting in a dark and cold storage locker wondering what they did wrong after several warm months in Florida.BSD爱好者乐园b?PAN*}#\ KZ)t

BSD爱好者乐园/s }F4fC }6gm

Just prior to leaving Florida, I threw POP servers onto my two mail servers and let the mail be delivered locally. Then I started using fetchmail on my laptop to grab the mail. This kept me connected, but it still wasn't quite what I wanted. It didn't meet all my needs, as outlined in the advantages listed above.

(J q f4S3?\f E]1BSD爱好者乐园,W.M2d E-@0A$r

I initially started into Cyrus IMAP, but abandoned it before deployment. I went with Dovecot. It is much easier to implement. Cyrus has its place, and is much more appropriate for larger environments. But I think it is overkill for my needs.BSD爱好者乐园O)L};S#H!Y6d;p?4\
BSD爱好者乐园ZU:R/m.OI,e

BSD爱好者乐园&[V|&Q|5|4L)@f j

As a strong advocate of the FreeBSD ports tree, you know I'll be using that. The install looks like this:BSD爱好者乐园Wt%q0n(P y

cd /usr/ports/mail/dovecot
e SR[|v/b g1make install clean
D [vc4T%VR5I/@1
BSD爱好者乐园dA_dI5} K

That's it. All the dependencies will be installed for you. That's very valuable. :)

YY&F!M,B+a1Configuration starts with the example file with some changes to suit my requirements.
cd /usr/local/etc
/ax:O,qfb&qp@1cp -i dovecot-example.conf dovecot.conf
7K9G J:L%aw1

nxN-\s'B%S'@ K[1A good source for configuration ishttp://wiki.dovecot.org/QuickConfiguration.

^ h?7cdrU1

w}2zZ|Z#k9z.M+c1Here is a diff which represents the changes I made. I will explain those inline.BSD爱好者乐园p@J-SQVT_

--- dovecot-example.conf	Wed Dec  5 15:27:25 2007BSD爱好者乐园!B:PH	WG
+++ dovecot.conf Wed Dec 5 19:15:12 2007
0v3e*i3M(P b\1@@ -21,7 +21,7 @@
CS~S5@ ?1# Protocols we want to be serving: imap imaps pop3 pop3s
4vY9@t:_%rF1# If you only want to use dovecot-auth, you can set this to "none".
7q'tr'tYVD.M,@2K1#protocols = imap imaps
,y D[:vc g%xQ&Z&``1-protocols = imap pop3
yA&O3aV5pgM yo1+protocols = imaps
:WA5r O Y U1
lq4bGH@C D s1# IP or host address where to listen in for connections. It's not currentlyBSD爱好者乐园.@Jg9vB)aS1p/n+A ~4R8A
# possible to specify multiple addresses. "*" listens in all IPv4 interfaces.BSD爱好者乐园6P)fF r"`$i7m~

&dlod#{]u$@ |I%\1I only want to run IMAPS (IMAP over SSL). This ensures all data transmitted is encrypted and cannot be viewed by others.BSD爱好者乐园(^UfH$y&F

@@ -93,12 +93,17 @@
9Gm(?5`.Sa4l1# root. Included doc/mkcert.sh can be used to easily generate self-signed
'Kc(j~]1s-f!H T1# certificate, just make sure to update the domains in dovecot-openssl.cnf
qZ$BTqx n1#ssl_cert_file = /etc/ssl/certs/dovecot.pem
F4V)hz#F1#ssl_key_file = /etc/ssl/private/dovecot.pem
5Ek4G fEi)~7~1BSD爱好者乐园8P\K%{f'R7o
+ssl_cert_file = /etc/ssl/certs/imaps.example.org.cert
6u h,W(R$ofb1+ssl_key_file = /etc/ssl/private/imaps.example.org.key
_x ~mS$K_1+
Q/jao"fdb!s2O1# If key file is password protected, give the password here. Alternatively
#w1P2C4Q:xT)v7Vlu1# give it when starting dovecot with -p parameter.BSD爱好者乐园1yOEM:@.e;y8],n
#ssl_key_password =BSD爱好者乐园 t7[TQ@M c&h
BSD爱好者乐园?tl}.m@knk
+ssl_key_password = ImNotTellingBSD爱好者乐园b zI X6d~I
+BSD爱好者乐园 l+c:A&Cv4~J9}8S
# File containing trusted SSL certificate authorities. Usually not needed.
,Hmlf K1# The CAfile should contain the CA-certificate(s) followed by the matchingBSD爱好者乐园&G4~h7fu~
# CRL(s). CRL checking is new in dovecot .rc1
\*h,p1\f1

r0J-| Ue)P1This sets up the certificates to be used by the encryption process. The details of how I created the certificate will be outlined below. The ssl_key_password directive supplies the passphrase for the certificate. No, that's not my real passphrase.

F\j.qy]mYv1BSD爱好者乐园R+p,m~ k0O%a:Y

The hostname of my IMAP server is imaps.example.org (not really, but it's an example).

_Xp4~$vT `3R7S1
@@ -211,7 +216,8 @@BSD爱好者乐园
?)UtD:u+b~
#BSD爱好者乐园 wN)t;EtF$o
#BSD爱好者乐园{'|irI
#mail_location =
5H ~K]!{%?cOe1-mail_location = mbox:~/mail/:INBOX=/var/mail/%uBSD爱好者乐园H3?\$J7sZ#kuN
+#mail_location = mbox:~/mail/:INBOX=/var/mail/%uBSD爱好者乐园ix*BHSg,}_Q
+mail_location = maildir:~/Maildir
h:`a aH1
j-|gwkU B8om[1# If you need to set multiple mailbox locations or want to change defaultBSD爱好者乐园 [)vr3A }"hyD
# namespace settings, you can do it by defining namespace sections.BSD爱好者乐园Y r"zZ)M$h(b9[!s
BSD爱好者乐园G.r\vV wa/K

I want to use the Maildir format, and I will place that Maildir in my home directory.

4mV:n)tt$o.|1
@@ -423,6 +429,8 @@
#h w4H"M.wG.GAZ~;]B+T P1# the performance much better, and it's unlikely to have any side effects.
d8Gp5k_1#maildir_copy_with_hardlinks = noBSD爱好者乐园L+P%W{:m8}4W kg

N5FH:Y l{1+maildir_copy_with_hardlinks = yesBSD爱好者乐园}3YK0L6d6p+F u!L
+BSD爱好者乐园7Hm:Kre.sN
# When copying a message, try to preserve the base filename. Only if the
t [Zv#Y)[L1# destination mailbox already contains the same name (ie. the mail is being
m1NfW-N[4m1# copied there twice), a new name is given. The destination filename check isBSD爱好者乐园-` I Y e4K0xi

xm'W4i C ^;}p1This is a simple performance issue. :)BSD爱好者乐园tV2J!U ~+r&{4\

@@ -787,6 +795,10 @@BSD爱好者乐园9X!h1Y)I#A
#args = /etc/dovecot.denyBSD爱好者乐园0n _+Vg&R{4cEG
#deny = yes
9wn#Q"e9B:B_x*q1#}BSD爱好者乐园 j.j oWe*~G0pr?6JO
+BSD爱好者乐园"c;Gm#n*UZ,yJ
+ passdb passwd-file {
u4Nuio {r1+ args = /var/db/dovecot.users
`'c(i.J/QL1+ }
&M;|*Lza:W1BSD爱好者乐园2w P)x4spDG I
# PAM authentication. Preferred nowadays by most systems.
T~GV.Vqi4A'O1# Note that PAM can only be used to verify if user's password is correct,BSD爱好者乐园j:Jq e R
BSD爱好者乐园\$N_{4nz$j/mi

I will use my own password file, and not use the system password file (/etc/passwd). I decided to do this to keep my IMAP login from my ssh login password.BSD爱好者乐园 | U2@up UxS?bj
BSD爱好者乐园4[u:?)_{+z*j0VI2v

BSD爱好者乐园8K,|bXBfZ(gT;K

I use CACert.org for my certificates. It is free and easy to do. I prefer not to use self-signed certificates, but there is no reason why you can't use them for this purpose. In a previous article about Bacula TLS, I showed how I did this. I will repeat the process here, in brief.

z3f0L"B-HD1
# openssl genrsa -des3 -out imaps.example.org.key 1024
n#NG7\%qM8MS1Generating RSA private key, 1024 bit long modulusBSD爱好者乐园9N w-wxcV6n8E
.......................................++++++BSD爱好者乐园&|lRL}Z ~X{|-j0wl5D
................................++++++
Qb:Qw Q*v1e is 65537 (0x10001)BSD爱好者乐园'[%od f+u
Enter pass phrase for imaps.example.org.key:BSD爱好者乐园8Fq$g:p _*_${%Fo
Verifying - Enter pass phrase for imaps.example.org.key:
kJ/a$z4o4Y1#BSD爱好者乐园$`v{2|b;bE#z
BSD爱好者乐园TQ*F5MB"sk

It is the above passphrase that you use in the dovecot.conf file with the ssl_key_password directive.

aiwyQHF1
# openssl req -new -key imaps.example.org.key -out imaps.example.org.csrBSD爱好者乐园Il{2qbw'\;?
Enter pass phrase for imaps.example.org.key:BSD爱好者乐园6ys#@sp'L*NNB"|
You are about to be asked to enter information that will be incorporated
B#EP1whr1into your certificate request.
:B]a X9_n2HdS3xu1What you are about to enter is what is called a Distinguished Name or a DN.
y$n3z3WC _#A8g1There are quite a few fields but you can leave some blankBSD爱好者乐园'tWQmO
For some fields there will be a default value,
,P5ua3B(z nDN?1j1If you enter '.', the field will be left blank.BSD爱好者乐园M'B|7zvPo!H
-----
{~"l"tTn1Country Name (2 letter code) [AU]:USBSD爱好者乐园J,au3ylj+J
State or Province Name (full name) [Some-State]:California
9R$J eW&Qh"Rn1Locality Name (eg, city) []:San JoseBSD爱好者乐园2\:z kA2_+u!m s-r
Organization Name (eg, company) [Internet Widgits Pty Ltd]:The FreeBSD Diary
o:h4?W4sJ ];d1Organizational Unit Name (eg, section) []:Gnome WrestlingBSD爱好者乐园c_"P@wU'W9OBq
Common Name (eg, YOUR name) []:imaps.example.orgBSD爱好者乐园VI0jmMEH
Email Address []:BSD爱好者乐园k4i(MkA6G7f_2w0E
BSD爱好者乐园;`,S4I&d v
Please enter the following 'extra' attributesBSD爱好者乐园2mh%D2I QK8A-\j
to be sent with your certificate request
J3o0?b5C(f&\n1A challenge password []:
`"jV2|#X$m1An optional company name []:
"M kG;OB&R1
BSD爱好者乐园9\7h2h_Ss


[重要提醒]对本篇资料有疑问,请到论坛讨论,尽量使文章准确无误>>>
[版权声明]BSD爱好者乐园站内文章,如来源不是互联网,则均系原创或翻译之作,可随意转载,或以此为基础进行演译,但务必以链接形式注明原始出处和作者信息,否则属于侵权行为。另对本站转载他处文章,俱有说明,如有侵权请联系本人,本人将会在第一时间删除侵权文章。
TAG: IMAP Dovecot

21/212>
 

评分:0

我来说两句

seccode