Hi Michael,
Accessing MySQL directly isn't slow, possibly slower than a lookup
table, however the email will eventually need to be inserted into the
database, so a simple select is nothing in comparison.
Here is the snippets of my config to get this going. Note that I have
used my own aliases table, as I found that when using the dbmail
aliases, dbmail was doing the aliases as well as postfix (so double-up
of mail), and for the spam scanner (dspam) to work as I want we need the
emails going out of postfix to the appropriate mailboxes.
If you don't want the aliases to be handled by postfix, just use the
mysql-mailboxes line. You might have to change the query to include the
aliases.
/etc/postfix/main.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-mailboxes.cf
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-aliases.cf
/etc/postfix/mysql-domains.cf
#
# mysql config file for virtual mailbox lookups
#
hosts = mysqlhost
# The user name and password to log into the mysql server.
user = dbmail
password = XXXXX
# The database name on the servers.
dbname = dbmail
query = SELECT domain FROM domains WHERE domain='%s'
/etc/postfix/mysql-mailboxes.cf
#
# mysql config file for virtual mailbox lookups
#
hosts = mysqlhost
# The user name and password to log into the mysql server.
user = dbmail
password = XXXXX
# The database name on the servers.
dbname = dbmail
query = SELECT userid FROM dbmail_users WHERE userid='%s'
/etc/postfix/mysql-aliases.cf
#
# mysql config file for virtual mailbox lookups
#
hosts = mysqlhost
# The user name and password to log into the mysql server.
user = dbmail
password = XXXXX
# The database name on the servers.
dbname = dbmail
query = select deliverto from forwards WHERE lower(origto) = lower('%s');
Additional schema to handle multiple domains and postfix-side
aliases/forwards:
CREATE TABLE `domains` (
`domain` varchar(100) NOT NULL,
PRIMARY KEY (`domain`)
) ENGINE=InnoDB;
CREATE TABLE `forwards` (
`id` int(11) NOT NULL auto_increment,
`origto` varchar(100) NOT NULL,
`deliverto` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `origto` (`origto`,`deliverto`),
KEY `email` (`origto`)
) ENGINE=InnoDB;
Michael Mayer wrote:
A questions to the dbmail experts on this list: Would there be any
other options than a cron script like this? I think I can remember a
way for Postfix to access MySQL directly, but this might be slow plus
you need compiled-in MySQL support (the Postfix version that comes
with Fedora 6 does not have this).
_______________________________________________
DBmail mailing list
[email protected]
https://mailman.fastxs.nl/mailman/listinfo/dbmail