Sunday, December 25, 2005

dbmail - How to

First of all I would like to share with you all my experience setting up a *testing* mailserver using dbmail as the imap and postfix as the smtp server and of course on Linux. This time I used Slackware Linux 10.2 and this server is actually behind a firewall. For overview what is dbmail, please visit dbmail.org or read previous posting.

Requirements
You need all of these:

  1. mysql server ( I used 4.1.14. This version supports InnoDB)*
  2. dbmail package ( i used version 2.0.7 )
  3. Postfix ( I used version 2.2.7 )
  4. DBMail source (get the latest from dbmail.org)
* Since some DBMail tables can get VERY large (depending on your mailusage) we advise using InnoDB as database storage backend.

Let's get dirty!
Make sure mysql is running. First you'll need to create the DBMail database in MYSQL. You can do this by issueing 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 ''

Where 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 <>Copy the dbmail.conf file to /etc and edit the dbmail.conf file and set everything in there to your likeings. Make sure to set your database name, user and host are configured in dbmail.conf. Other options in the configuration file are documented there.

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

For MySQL,

./configure --with-mysql

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

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-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 -w -g -m [-s 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. 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 mailserver deliveres to.

example:

./dbmail-users -a zamri -w puttycat -g mail -m 25M -s zamri@dude.org zamri@dude.net @net.com

This will create a user zamri, with a password puttycat. It will set zamri's maillimit 25 Mb and all mail for zamri@dude.org, zamri@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 zamri.

Now for the postfix, i have to add this line in /etc/postfix/master.cf

dbmail-lmtp unix - - n - - lmtp

If you want verbose output in the mail log, add -v to lmtp, like this:

dbmail-lmtp unix - - n - - lmtp -v

Note : This is good for troubleshooting. Don't underestimate it but please note that you get a LOT of output in your logs when using this setting.

Now edit main.cf and add / change the mailbox_transport directive to:

mailbox_transport = dbmail-lmtp:localhost:24 ^
local_transport = dbmail-lmtp:localhost:24 *

*Note: This one to make sure local mail delivery to dbmail.
^Note: This is the step to make sure the mails use dbmail's transport but not including local delivery.

And then set this :

local_recipient_maps =

Note : This step is *VERY* important or mails from outside can not reach your mailbox. See INSTALL.postfix in source for more info.

Afterthat run this commands:

postmap /etc/postfix/transport
postfix reload

Run the dbmail's servers:

dbmail-lmtpd
dbmail-imapd

Make sure postfix and MySQL (or PostgreSQL) are running. Try sending and replying to local users first and if successful, you can then try the same to outside users.

2 comments:

Unknown said...

Hello

Thank you for your post *thumbs up*

One SQL-command is a bit strange:
GRANT ALL ON dbmail.* to dbmail@localhost identified by ''

The '' looks like a " ... maybe a 'password' would be more clear ;)

BR,
lousek

Zamri said...

Sorry lousek1992 for that but I have explained it should be password in the ''.

Thanks for the comment anyway. :)

Cheers.

Second monitor no display after latest update - KDE-neon

 After latest update as of Oct 3, 2023, my second monitor was undetected with latest kernel (6.2.0-33-generic). If I boot with previous kern...