Setting up Postfix with PosgreSQLon FreeBSD

Peter Schuller peter.schuller at infidyne.com
Mon Nov 22 15:59:19 PST 2004


Hello,

> Thanks for responding, Ryan, but I'm confused. I have managed to start
> postgres with a user I called pgsql. The install appears to do that with
> a user called postgres but doesn't reference postfix. How do I tell
> postfix that I want to use postgres?

Basically in main.cf you must specify postgresql databases rather than the 
default ones. For example, on one machine where I use Postfix+PostgreSQL, I 
have (among other things):

alias_maps = pgsql:/usr/local/etc/postfix/pgsql-localaliases.cf
virtual_alias_maps = pgsql:/usr/local/etc/postfix/pgsql-aliases.cf
virtual_mailbox_maps = pgsql:/usr/local/etc/postfix/pgsql-mailboxes.cf

Each of the files referenced contains the information postfix needs in order 
to query the postgresql database. For example, pgsql-localaliases.cf 
contains:

hosts = localhost
user = mail
password = YOUR_DB_PASSWORD_HERE
dbname = YOUR_PG_DB_NAME_HERE
table = bla
query = SELECT local_alias.target FROM local_alias WHERE \
                          local_alias.address ILIKE '%s';

(linebreak added for readability)

The 'table' option is not needed, but IIRC when testing it would bail if the 
keyword itself was missing, even though it was never used since I opted for 
the 'query' option instead (hence "bla"). Instead of specifying the query 
like that, one can specify individual parts using table/where statements. I 
found it easier to just specify the whole query so that I know what's going 
on.

I haven't been following this thread so I don't know how much you already know 
or whether this helps. If this doesn't clear things up let me know and I can 
provide some URLs that are suitable for reading on this issue, and/or more 
details. At the moment I'm in a bit of a hurry.

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller at infidyne.com>'
Key retrieval: Send an E-Mail to getpgpkey at scode.org
E-Mail: peter.schuller at infidyne.com Web: http://www.scode.org



More information about the freebsd-questions mailing list