summaryrefslogtreecommitdiff
blob: b11a804fc3eab7370fcdc1702fb07b8d40e53e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// This quick guide is for mysql authentication support base on the Gentoo Virtual Mailhosting Guide
// turn ON mysql USE flag for courier-authlib. Need to authenticate against mysql database backend.
localhost ~ # nano -w /etc/portage/package.use
net-libs/courier-authlib mysql
net-mail/courier-imap mysql
localhost ~ # emerge courier-imap
// limit to mysql module only, instead load all of them.
localhost ~ # nano -w /etc/courier/authlib/authdaemonrc
authmodulelist="authmysql"

// set variables to match your setup.
localhost ~ # nano -w /etc/courier/authlib/authmysqlrc
MYSQL_SERVER            localhost
MYSQL_USERNAME          mailsql_admin_username
MYSQL_PASSWORD          password
MYSQL_DATABASE          mailsql_database
MYSQL_USER_TABLE        users
# MYSQL_CRYPT_PWFIELD   crypt (commented this out if you want CRAM-MD5)
MYSQL_CLEAR_PWFIELD     clear
MYSQL_LOGIN_FIELD       email
MYSQL_HOME_FIELD        homedir
MYSQL_MAILDIR_FIELD     maildir

// Start authdaemond
localhost ~ # etc/init.d/courier-authlib start
* Starting courier-authlib: authdaemond ...                                               [ ok ]

### Courier-IMAP' ssl certificate setup
localhost ~ # nano -w /etc/courier-imap/imapd.cnf
localhost ~ # nano -w /etc/courier-imap/pop3.cnf
// change to match your site.
[ req_dn ]
C=US
ST=NY
L=New York
O=Courier Mail Server
OU=Automatically-generated IMAP SSL key
CN=mailhost.example.com
emailAddress=postmaster@example.com

// Generate Certificate
localhost ~ # mkimapdcert
...
writing new private key to '/etc/courier-imap/imapd.pem'
...
localhost ~ # mkpop3dcert
...
writing new private key to '/etc/courier-imap/pop3d.pem'
...

### Secure Authentication Setup (CRAM-MD5)
localhost ~ # nano -w /etc/courier-imap/imapd
IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=CRAM-MD5"

### Start Courier-imap daemons.
localhost ~ # /etc/init.d/courier-pop3d start
localhost ~ # /etc/init.d/courier-pop3d-ssl start
localhost ~ # /etc/init.d/courier-imapd start
localhost ~ # /etc/init.d/courier-imapd-ssl start

### Checking authentication.
// From your favorite client send an email to user@your_domain.com
// so your mail user's maildir created by your MTA.
// you can not login unless user maildir has been created.
localhost ~ $ telnet mailexample.com 143
Trying xxx.xxx.xxx.xxx...
Connected to mail.example.com (xxx.xxx.xxx.xxx).
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=CRAM-MD5 ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2004 Double Precision, Inc.  See COPYING for distribution information.
a login user@example.com password
a OK LOGIN Ok.
 OK LOGOUT completed
Connection closed by foreign host.

### That's all folks.