I used the method you describe, but with an additional tweak for
PostgreSQL:
1. No need to have a separate table to define virtualhosts; simply write
a view to extract the domain name component of the email aliases:
CREATE VIEW dbmail_virtualhosts AS
SELECT DISTINCT
split_part(dbmail_aliases.alias::text, '@'::text, 2) AS "domain",
'dbmail-lmtp:'::text AS transport
FROM dbmail_aliases
ORDER BY split_part(dbmail_aliases.alias::text, '@'::text, 2), 2;
2. Some might complain about performance implications of a view based on
a text manipulation function, but PostgreSQL allows you to create
indexes on the use of any function in a table:
CREATE INDEX dbmail_aliases_domains ON dbmail_aliases USING btree
(split_part(alias::text, '@'::text, 2))
(note that the PostgreSQL version of DBMail already has a functional
index for the use of the lower() function for dbmail_aliases, also)
So far, I have found this to perform quite well in a modest production
environment (Dual-processor P3/SCSI, FreeBSD 4.10, PostgreSQL 7.4.5).
Jeff Brenton wrote:
Hello Nathan,
NZ> I was under the impression that this was what has happening. How
NZ> do I tell postfix to just use mysql and not mydestination? I am a
NZ> novice here so please dummy it down for me.
The first thing to do is make sure your copy of postfix is compiled
with SQL capability to match the database you're using. I don't have
time to go into how to do that right now, but it is necessary for SQL
transport maps AND the pop-before-smtp authentication to work.
After that, you need to follow this advice from a previous post I
made here, for MySQL tables:
When querying the table for mydestination, postfix ONLY needs to have
a valid row returned. When querying for transport, it wants the
routing returned.
Excerpt from main.cf:
---
mydestination = mysql:/etc/postfix/my_trans.cf
transport_maps = mysql:/etc/postfix/my_trans.cf
---
Partial contents of forwarder.mytransport table:
---
id domain transport comment
1 csrye.org dbmail: First Test
2 espi.com dbmail: Second test victim
3 cruftware.com dbmail:
4 dididahdahdidit.com dbmail:
---
my_trans.cf contents:
---
user = postfix
password = [password]
dbname = forwarder
table = mytransport
hosts = 192.168.2.142
select_field = transport
where_field = domain
---
The same configuration file works for both, because Postfix doesn't
care what is returned the first time, just that a row was found.
-------
You can also have Postfix look at the dbmail aliases table to
determine whether or not an address is deliverable, using the
local_recipient_maps parameter:
local_recipient_maps = mysql:/etc/postfix/mailbox.cf
where mailbox.cf is similar to my_trans.cf above, except points to the
dbmail aliases table.