/* $Id: INSTALL,v 1.1.1.1 2002/07/24 12:23:44 arto Exp $ 
   (c) 2000-2001 IC&S, The Netherlands */

DBMAIL installation
===================

What do you need?

- a working MYSQL database
- a working smtp server (preferrably Postfix)
- a little knowledge about SQL

If you follow the steps below you'll have DBMAIL running in no-time.


1.	First yu'll need to create the DBMAIL database in MYSQL.
	This is easy. You'll need the mysql commandline program for this. 
	Just do :
	
	mysql -u root -p <sql/create_tables.sql
	
	in the dbmail source tree.
	After this, the DBMAIL tables will have been created.


2. Look at the config.h file in the dbmail source directory. You will see a few #define
	statements. First the #define HOST should contain the hostname of the 
	machine that runs the MYSQL database. USER and PASS need to be replaced
	with a user and password that can access the DBMAIL database. 

	Do a find or a locate for mysql.h. Copy this path and set it in the 
	dbmysql.h in the #include "full path to mysql.h"

	If you want verbose debugging you can set the TRACE_LEVEL to 4 or 5. 
	For normal messages the TRACE_LEVEL should be 2. If you experience any problems
	you can send an e-mail to the mailinglist. If you include a TRACE level 5 log
	chances are that your problem is fixed quite fast :)

	In the Makefile you might want to check the location for the mysqlclient file
	(the MYSQLLIBDIR variable). 

	
3.	Run make 
	Everything should go ok. If not, it usually means that the compiler 
	can't find the mysqlclient library or the mysqlclient header file. If that happends,
	go back to number 2 and check if everything is ok.

	After the make the following binaries should have been created:
	dbmail-smtp				- the dbmail mailinjector
	dbmail-pop3d			- the dbmail pop3 daemon
	dbmail-imapd			- the dbmail imap4r1 daemon
	dbamil-maintenance	- the dbmail maintenance tool
	dbmail-config			- the dbmail configuration program
	dbmail-adduser			- the dbmail user add program


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

	dbmail-adduser <username> <password> <clientid> <maxmail> [aliases]
	
	clientid can be left 0 (this is if you want certain mailadministrators administer 
	specific groups of mailusers). maxmail is the maximum number of bytes this user may
	have in his/her mailboxes. 0 is unlimited. 
	aliases are a number of aliases for this user. @domain are domain aliases.
	
	example: 
	./dbmail-adduser john secret 0 25000000 john@dude.org john@dude.net @net.com
	This will create a user john, with a password secret. It will set john's maillimit
	25 Mb and all mail for john@dude.org, john@dude.net and @net.com will be sent to john.

	Be carefull, the adduser does not (yet) check if a user already exists!


5.	
	Become root and run install-dbmail.sh which will install the dbmail executables.


6. check your dbmail.conf file and set it to your likeings. After that you can 
	best copy it to the /etc/ directory and set it to chmod 600 for the user dbmail
	runs as.
	Don't forget to run dbmail-config /etc/dbmail.conf everytime you make changes
	to the dbmail.conf file!


-- The next lines are MTA dependend, this is for postfix --
	
7.	In the master.cf file for postfix add the following:
	
	dbmail    unix  -       n       n       -       -       pipe
	    flags=  user=dbmail:dbmail argv=/usr/local/sbin/dbmail-smtp -d ${recipient}

	at the user= field you can add any user that is allowed to run dbmail-smtp. 
	I suggest adding a user dbmail with a group dbmail and have all dbmail programs 
	be run by that user. The daemons (pop3d and imapd) are fully capable of dropping their 
	root priviledges after startup.

	and insert into the /etc/postfix/transport file 

	<domain>		dbmail:

	for all domains you want dbmail to be destiation for.
	
	Next run postmap /etc/postfix/transport

	Edit /etc/postfix/main.cf and add the line 
	transport_maps = hash:/etc/postfix/transport

	do a postfix reload and if everything goes well 
	mail should be delivered to dbmail. If not, try running 
	postfix with the -v option to see what's going on. If the 
	problem seems to be in dbmail, try changing the tracelevel in dbmail.conf
	and don't forget to run dbmail-config ./dbmail.conf afterwards.
	This should give enough info. 

--  -----------------------------------------------------------

If you do not use postfix. The dbmail injector program, dbmail-smtp,
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 commandline using the -d option. Be carefull, the -n option is not fully 
tested and may behave unexected. If possible use the -d option.

Steven Kroon <steven@stevenkroon.com> suggested using fetchmail:

Your .fetchmailrc file should look like:

--
defaults        proto   pop3
			user "myusername"
			poll "your pop3 server"
			pass "mypasswd"
								 
mda "/usr/local/bin/dbmail-smtp -n to"
---

If u get dbmail running on other MTA's please tell me at
the mailinglist. For other problems you can subscribe to the dbmail
mailinglist : https://mailman.fastxs.nl/mailman/listinfo/dbmail
