1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx P
\bPo
\bos
\bst
\btg
\bgr
\bre
\beS
\bSQ
\bQL
\bL H
\bHo
\bow
\bwt
\bto
\bo
3 -------------------------------------------------------------------------------
5 I
\bIn
\bnt
\btr
\bro
\bod
\bdu
\buc
\bct
\bti
\bio
\bon
\bn
7 The Postfix pgsql map type allows you to hook up Postfix to a PostgreSQL
8 database. This implementation allows for multiple pgsql databases: you can use
9 one for a virtual(5) table, one for an access(5) table, and one for an aliases
10 (5) table if you want. You can specify multiple servers for the same database,
11 so that Postfix can switch to a good database server if one goes bad.
13 Busy mail servers using pgsql maps will generate lots of concurrent pgsql
14 clients, so the pgsql server(s) should be run with this fact in mind. You can
15 reduce the number of concurrent pgsql clients by using the Postfix proxymap(8)
18 B
\bBu
\bui
\bil
\bld
\bdi
\bin
\bng
\bg P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx w
\bwi
\bit
\bth
\bh P
\bPo
\bos
\bst
\btg
\bgr
\bre
\beS
\bSQ
\bQL
\bL s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt
20 These instructions assume that you build Postfix from source code as described
21 in the INSTALL document. Some modification may be required if you build Postfix
22 from a vendor-specific source package.
24 Note: to use pgsql with Debian GNU/Linux's Postfix, all you need to do is to
25 install the postfix-pgsql package and you're done. There is no need to
28 In order to build Postfix with pgsql map support, you specify -DHAS_PGSQL, the
29 directory with the PostgreSQL header files, and the location of the libpq
35 % make -f Makefile.init makefiles \
36 'CCARGS=-DHAS_PGSQL -I/usr/local/include/pgsql' \
37 'AUXLIBS=-L/usr/local/lib -lpq'
41 C
\bCo
\bon
\bnf
\bfi
\big
\bgu
\bur
\bri
\bin
\bng
\bg P
\bPo
\bos
\bst
\btg
\bgr
\bre
\beS
\bSQ
\bQL
\bL l
\blo
\boo
\bok
\bku
\bup
\bp t
\bta
\bab
\bbl
\ble
\bes
\bs
43 Once Postfix is built with pgsql support, you can specify a map type in main.cf
47 alias_maps = pgsql:/etc/postfix/pgsql-aliases.cf
49 The file /etc/postfix/pgsql-aliases.cf specifies lots of information telling
50 postfix how to reference the pgsql database. For a complete description, see
51 the pgsql_table(5) manual page.
53 E
\bEx
\bxa
\bam
\bmp
\bpl
\ble
\be:
\b: l
\blo
\boc
\bca
\bal
\bl a
\bal
\bli
\bia
\bas
\bse
\bes
\bs
56 # pgsql config file for local(8) aliases(5) lookups
60 # The hosts that Postfix will try to connect to
61 hosts = host1.some.domain host2.some.domain
63 # The user name and password to log into the pgsql server.
65 password = some_password
67 # The database name on the servers.
68 dbname = customer_database
70 # Postfix 2.2 and later The SQL query template. See pgsql_table(5).
71 query = SELECT forw_addr FROM mxaliases WHERE alias='%s' AND status='paid'
73 # For Postfix releases prior to 2.2. See pgsql_table(5) for details.
74 select_field = forw_addr
77 # Don't forget the leading "AND"!
78 additional_conditions = AND status = 'paid'
80 U
\bUs
\bsi
\bin
\bng
\bg m
\bmi
\bir
\brr
\bro
\bor
\bre
\bed
\bd d
\bda
\bat
\bta
\bab
\bba
\bas
\bse
\bes
\bs
82 Sites that have a need for multiple mail exchangers may enjoy the convenience
83 of using a networked mailer database, but do not want to introduce a single
84 point of failure to their system.
86 For this reason we've included the ability to have Postfix reference multiple
87 hosts for access to a single pgsql map. This will work if sites set up mirrored
88 pgsql databases on two or more hosts.
90 Whenever queries fail with an error at one host, the rest of the hosts will be
91 tried in random order. If no pgsql server hosts are reachable, then mail will
92 be deferred until at least one of those hosts is reachable.
94 C
\bCr
\bre
\bed
\bdi
\bit
\bts
\bs
96 * This code is based upon the Postfix mysql map by Scott Cotton and Joshua
97 Marcus, IC Group, Inc.
98 * The PostgreSQL changes were done by Aaron Sethman.
99 * Updates for Postfix 1.1.x and PostgreSQL 7.1+ and support for calling
100 stored procedures were added by Philip Warner.
101 * LaMont Jones was the initial Postfix pgsql maintainer.
102 * Liviu Daia revised the configuration interface and added the main.cf
103 configuration feature.
104 * Liviu Daia revised the configuration interface and added the main.cf
105 configuration feature.
106 * Liviu Daia with further refinements from Jose Luis Tallon and Victor
107 Duchovni developed the common query, result_format, domain and
108 expansion_limit interface for LDAP, MySQL and PosgreSQL.
109 * Leandro Santi updated the PostgreSQL client after the PostgreSQL developers
110 made major database API changes in response to SQL injection problems, and
111 made PQexec() handling more robust.