Helgrim.com

If you had two brains, you'd be twice as stupid. 
[Index of articles]

Content

1 Introduction
2 Requirements
3 Download
4 Setup a database
5 Build Dbmail
6 Install DBMail
7 Configure dbmail.conf
8 Create users in the dbmail system
9 Configure your MTA
10 Setting up the maintenance run

1 Introduction

DBMAil is a Mail Delivery Agent and, as such, can be used with a multitude of mail servers. It uses a database to store it's information, and currently runs on either
PostgreSQL, or Mysql.
[Comment on this ]

[Table of Contents]  [Top of section]  

2 Requirements

Dbmail should run on any UNIX or similar system, including Linux, FreeBSD, OpenBSD, Mac OS X.

You will require an MTA (Mail Transport Agent) which is capable of passing emails to external programs.
Sendmail and qmail are two such examples.

You will also require either PostgreSQL or MySQL to provide the backend database. At present, Dbmail does not work with Oracle.
[Comment on this ]

[Table of Contents]  [Top of section]  


3 Download

Download the latest version of Dbmail from http://www.dbmail.org/download.phtml to your home directory, and unzip it as follows:

$ tar -zxf dbmail.x.y.tgz
$ cd dbmail.x.y


[Comment on this ]

[Table of Contents]  [Top of section]  


4 Setup a database

You must have either PostgreSQL or MySQL installed. Instructions on this is outside the scope of this document, instead refer to their respective websites. If you plan on using MySQL in a large installation, it is recommended that you include InnoDB support for MySQL.

[Comment on this ]

[Table of Contents]  [Top of section]  

5 Build Dbmail

Now add a user and group called 'dbmail' which Dbmail will run as. The procedure to do this can vary from system to system so you may need to consult your system documentation.
# adduser dbmail

Dbmail comes with two scripts called build.sh and install-dbmail.sh which build and install dbmail respectively. Note however, both build.sh and install-dbmail.sh use certain programs during the installation process, and have the paths to these programs hardcoded in the scripts. For example, install-dbmail.sh uses chown and expects it's path to be /bin/chown. However, on some systems this is /usr/sbin/chown, so you may need to edit the scripts before using them. Also, install-build.sh uses bash2, if you are using bash1, you should download this patch, and save it to the dbmail source directory, and run
$ patch install-dbmail.sh < install-dbmail.sh.patch

If you are happy that these scripts are correct, you can build the binaries using the build.sh script. This will ask you a number of questions about your installation, such as where the include and lib directories for your database are.
$ bash build.sh
This is the dbmail build script
I will have to ask you some questions about your system


What database do you wish to use? Choices are (m)ysql and (p)ostgresql >

If you select MySQL, the following will be asked:
You have selected MySQL as database
The library directory for MySQL is now [/usr/local/lib/mysql/].
Enter new directory or press RETURN to keep this setting:

You can check this with the command mysql_config -libs
The include directory for MySQL is now [/usr/include/mysql/].
Enter new directory or press RETURN to keep this setting:

You can check this with the command mysql_config -cflags
The libraries are currently set to [-lmysqlclient -lcrypto]. Enter new libraries (preceed each by -l) or press RETURN to keep this setting:

Again, you can check this with mysql_config -libs


If you selected postgres as your database, the following questions will be asked:
You have selected PostgreSQL as database
The include directory for PostgreSQL is now [/usr/local/pgsql/include/].
Enter new directory or press RETURN to keep this setting:

Check this with pg_config --libdir
The library directory for PostgreSQL is now [/usr/local/pgsql/lib/].
Enter new directory or press RETURN to keep this setting:

Check this with pg_config --includedir
The libraries are currently set to [-lpq -lcrypto -lssl].
Enter new libraries (preceed each by -l) or press RETURN to keep this setting:

These *should* be fine...

Creating makefile..

Done. You can now make dbmail by running 'make clean all'.
Do you want this to be executed right now?

You can either continue to build dbmail now, or answer n, and run make clean all seperately.
y

[snip]

Make succesfull. Do you want to install the binaries and man pages?

If you ran build.sh as root, you can just answer yes, other wise, you will need to answer no and install it manually (see next section)

[Comment on this ]

[Table of Contents]  [Top of section]  


6 Install DBMail

Finally, to install dbmail, run the following as root:
# bash install-dbmail.sh
This script will install dbmail on your system. Before executing this script be sure to have read the INSTALL file.
Although dbmail is very easy to install you'll need to know a few little things before you can start using it.

If you have any problems, man files will also be installed so you can
always check the manpage of a program.

Next i'll be asking you as what user and group you want to be running DBMAIL.
Best thing is to create a user called dbmail with a dbmail group.
Don't forget to edit these users in the dbmail.conf file and run dbmail-config
afterwards. The pop3 daemon and the imapd daemon have capabilities to
drop their privileges! Use that capability!

As what user are the dbmail daemons going to run? [default: dbmail]

dbmail should be fine here
As what group are the dbmail daemons going to run? [default: dbmail]

dbmail should be fine here
Ok installing dbmail executables as dbmail:dbmail..
Ok installing manfiles in /usr/local/man/man1/..
Done

Dbmail should now be installed on your system.


[Comment on this ]

[Table of Contents]  [Top of section]  

7 Configure dbmail.conf

Copy the dbmail.conf file to /etc/dbmail.conf:

# cp dbmail.conf /etc/dbmail.conf
# chmod 0600 /etc/dbmail.conf

Now edit /etc/dbmail.conf in your preferred text editor and set the appropiate values. dbmail.conf is split into four sections as follows:


[Comment on this ]


[Table of Contents]  [Top of section]  

8 Create users in the dbmail system

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 do the following:
# dbmail-adduser a <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.
A user always needs to have at least one alias to receive mail.
example:
$ dbmail-adduser a 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. 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.


[Comment on this ]

[Table of Contents]  [Top of section]  

9 Configure your MTA

Dbmail is known to work with sendmail, postfix, and qmail. It should however work with any MTA which allows emails to be passed to external scripts. 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 unexpectedly. If possible use the -d option.
[Comment on this ]

[Table of Contents]  [Top of section]  

10 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-maintanance program. This program will also check the integrity of the dbmail database and, if nescessary, fix it.

The dbmail-maintenance 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-maintenance program in a daily interval from cron:

0 3 * * * /usr/local/sbin/dbmail-maintenance -cfpd >> /dev/null 2>&1

[Comment on this ]

[Table of Contents]  [Top of section]  
© Feargal Reilly 2003-2009 | feargal@helgrim.com | Hosting by FBI | Valid HTML 4.01 | Valid CSS