summaryrefslogtreecommitdiff
path: root/INSTALL
blob: 9e2096deedea00527b24289499a13b8a4184dd6e (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 (c) 2000-2004 IC&S, The Netherlands 
 (c) 2004-2010 NFG Net Facilities Group BV, The Netherlands, support@nfg.nl

FIXME: this information is somewhat outdated
TODO:
tell more about where to find what library
add information about utf8 setups for mysql users
add information about advanced setups with connection pools

*/

DBMAIL Installation
===================

What do you need?

- A working database, one of the following:
  - MySQL 4.1.3 or higher with InnoDB.
  - PostgreSQL 7.4 or higher.
  - SQLite 3 or higher.
- A working SMTP server (such as Postfix, Exim, QMail or Sendmail).
- The DBMail source (www.dbmail.org).
- GNU Make. On Linux systems, your standard 'make' program is GNU Make. On *BSD
  systems, make sure you install and use 'gmake'. 
- Development files (libs, scripts and include files) for your database server.
  These will probably be provided by separate packages.
- Glib (>= 2.8) development headers and libraries.
- Gmime (>= 2.1.18) development headers and libraries.
- libSieve for Sieve support (libsieve.sf.net).
- Any standard libldap for LDAP support (only tested with OpenLDAP, however).
- mhash
- openssl
- libzdb (http://www.tildeslash.com/libzdb/)
- libevent


1.	Setup a database

	MySQL setup
	-----------

	First you'll need to create the DBMail database in MYSQL. You can do
	this by issuing the following command. This step is only necessary when
	you do not have a database for DBMail yet. Note that you will be
	prompted for the MySQL root password.

	mysqladmin create dbmail -u root -p

	This creates a database with the name "dbmail". Now you have to give
	a non-root user access to this database. Start the MySQL command-line
	client as root:

	mysql -u root -p 

	and enter the following command:

	GRANT ALL ON dbmail.* to dbmail@localhost identified by '<pass>'

	Where <pass> should be replaced with the password you want for
	the dbmail user. After this step, the database is ready to be
	used by the dbmail user. The next step is the creation of the
	database tables used by DBMail. Log out of the MySQL client and run 
	the following command from the command line. You will have to
	enter the password you set in the previous step.

	mysql -u dbmail dbmail -p < sql/mysql/create_tables.mysql

	After this, the DBMAIL tables will have been created and we can go
	on to the compilation and installation of DBMail itself.

	PostgreSQL setup
	----------------
	
	First you need to create the PostgreSQL user dbmail is going to use.
	This is done by. Note that this command can only be performed by
	user postgres or another PostgreSQL user with the privileges to
	create users and and databases.

	createuser -U postgres dbmail

	Off course you can use an other username than dbmail, simply replace
	it. You can set a password for the user by doing a:

	ALTER USER dbmail WITH PASSWORD '<password>';

	In a PostgreSQL console, with <password> replaced by the actual 
	password you want to use. After doing this you should create the
	database for dbmail:

	createdb -E utf8 -U postgres -O dbmail dbmail

	The first dbmail is the user you just created, the second the name of
	the database. Of course you can use an other database name. After
	setting up the user and database it's time to create the tables, do a:

	psql -U dbmail -h localhost dbmail < sql/postgresql/create_tables.pgsql

	Don't forget to start postgresql with the -i option, so it accepts
	TCP/IP connections.

	SQLite setup
	------------

	Dbmail will automatically create the database specified in dbmail.conf. 
	All you need to do is make sure that the directory which will contain
	the database file exists, and is writable for the dbmail user.

2. 	Set the database settings

	Copy the dbmail.conf file to /etc
	Edit the dbmail.conf file and set everything in there
	to your likings.

	Make sure to set your database name, user and host are configured
	in dbmail.conf. Other options in the configuration file are 
	documented there.

3.	Run configure & make
	Run the configure script. This script uses pg_config or mysql_config
	(depending on --with-mysql or --with-pgsql) to detect where the
	libraries and include files for these databases are.

	e.g. when working with PostgreSQL, this is the configure command:

	./configure --with-pgsql

	After running configure, 'make all' will build the executables.
	
	Running 'make install' will install the executables in /usr/local/sbin

4.	Create users in the dbmail system

	Next you will need to create some users into the dbmail mailing system.
	Currently this can be done in two ways. One way is using the
	dbmail-users utility. The other way is doing it in the database
	itself. To do it using the dbmail-users utility and do the following:

	dbmail-users -a <username> -w <password> -g <clientid> -m <maxmail> [-s aliases]
	
	clientid can be left 0 (this is if you want certain mail administrators
	administer specific groups of mail users). maxmail is the maximum
	number of bytes this user may have in his/her mailboxes. 0 is
	unlimited. Add K or M for kilobytes and megabytes. Aliases are a 
	number of aliases for this user. @domain are domain aliases. 
	A user always needs to have at least one alias to receive mail, unless
	the users username is something like foo@bar.org, where bar.org is 
	a domain the mail server delivers to.
	
	example: 
	./dbmail-users -a john -w secret -g 0 -m 25M -s john@dude.org,john@dude.net,@net.com
	
	This will create a user john, with a password secret. It will set
	john's mail limit 25 Mb and all mail for john@dude.org, john@dude.net
	and @net.com will be sent to john. The @net.com is a fallback alias.
	This means that all mail that cannot be delivered to an existing alias
	for a @net.com address will sent to john.

5.	Configure your MTA 

	There are two ways to connect your MTA to DBMail. The MTA can start a
	dbmail-deliver process and pipe SMTP commands and messages to it, or it
	can use LMTP (Local Mail Transport Protocol) to deliver via
	dbmail-lmtpd. LMTP is the preferred solution because it offers more
	robust error handling and because it is a daemon, high traffic servers
	will have reduced delays which would be incurred starting up a
	dbmail-deliver process for each message.

	The specifics of delivering to DBMail from your MTA can be found in the
	README.<MTA Name> files. Currently there is documentation for Postfix,
	Exim and QMail. Other setup information can also be found on the
	project wiki, at http://www.dbmail.org/dokuwiki

	If you use a different kind of MTA that we do not have documentation
	for: The dbmail injector program, dbmail-deliver, can receive information
	in two ways. Either through raw mail (for example, delivered by
	procmail) using the -n option or from a MTA with recipients in the
	command line using the -d option. Be careful, the -n option is not
	fully tested and may behave unexpected. If possible use the -d option.

	Setup for LMTP should be straightforward if your MTA supports it.

6.	Setting up the maintenance run

	The dbmail daemons and the smtp injector itself will never actually
	delete mail from the database. The only program that will do this is
	the dbmail-util program. This program will also check the integrity of
	the dbmail database and, if necessary, fix it. The dbmail-util program
	will first delete all messages that are set for final deletion. After
	that it will set all messages that have the delete status set to status
	final deletion. This way dbmail always has a backup based upon the
	interval difference between maintenance jobs. We recommend running the
	dbmail-util program in a daily interval from cron:

	0 3 * * * /usr/local/sbin/dbmail-util -ay &>/dev/null
	
7.	Starting the servers

	If you want users to be able to retrieve email via IMAP or POP3, run
	dbmail-imapd and/or dbmail-pop3d. If you are delivering email via
	LMTP, run dbmail-lmtpd (you should start LMTP before your MTA!).

8.	Problems
	--------
	For problems you can subscribe to the dbmail mailing list: 
	http://mailman.fastxs.nl/mailman/listinfo/dbmail
	
	Please also check the mailing list archives,
	the wiki at: http://www.dbmail.org/dokuwiki
	and the bugs at: http://www.dbmail.org/mantis

	Please note that DBMail logs a lot of relevant data to the mail log
	(often located at /var/log/maillog or /var/log/mail.log). This can
	help you often if something is not working, e.g. if there's no
	connection to the database.