@@ -16,8 +16,8 @@ smtpd.conf(5).
1616
1717# POSTGRESQL TABLE
1818
19- A postgresql table allows the storing of usernames, passwords, aliases, and domains
20- in a format that is shareable across various machines that support
19+ A postgresql table allows the storing of usernames, passwords, aliases, and
20+ domains in a format that is shareable across various machines that support
2121postgres(1).
2222
2323The table is used by
@@ -33,7 +33,8 @@ databases with one or more tables.
3333If the table is used for authentication, the password should be
3434encrypted using the
3535crypt(3)
36- function. Such passwords can be generated using the
36+ function.
37+ Such passwords can be generated using the
3738encrypt(1)
3839utility or
3940smtpctl(8)
@@ -52,49 +53,56 @@ The following configuration options are available:
5253> Connection info needed to connect to the PostgreSQL database.
5354> For example:
5455
55- > ** conninfo**
56- > ** host** =* 'db.example.com'*
57- > ** user** =* 'maildba'*
58- > ** password** =* 'OpenSMTPDRules!'*
59- > ** dbname** =* 'opensmtpdb'*
56+ > > conninfo host='db.example.com' user='maildba' password='...' dbname='opensmtpdb'
6057
6158** query\_ alias**
6259* SQL statement*
6360
64- > This is used to provide a query to look up aliases. The question mark
65- > is replaced with the appropriate data. For alias it is the left hand side of
66- > the SMTP address. This expects one VARCHAR to be returned with the user name
67- > the alias resolves to.
61+ > This is used to provide a query to look up aliases.
62+ > The question mark is replaced with the appropriate data.
63+ > For alias it is the left hand side of the SMTP address.
64+ > This expects one VARCHAR to be returned with the user name the alias
65+ > resolves to.
6866
6967** query\_ credentials**
7068* SQL statement*
7169
72- > This is used to provide a query for looking up user credentials. The question
73- > mark is replaced with the appropriate data. For credentials it is the left
74- > hand side of the SMTP address. The query expects that there are two VARCHARS
75- > returned, one with a user name and one with a password in
70+ > This is used to provide a query for looking up user credentials.
71+ > The question mark is replaced with the appropriate data.
72+ > For credentials it is the left hand side of the SMTP address.
73+ > The query expects that there are two VARCHARS returned, one with a user
74+ > name and one with a password in
7675> crypt(3)
7776> format.
7877
7978** query\_ domain**
8079* SQL statement*
8180
82- > This is used to provide a query for looking up a domain. The question mark
83- > is replaced with the appropriate data. For the domain it would be the
84- > right hand side of the SMTP address. This expects one VARCHAR to be returned
85- > with a matching domain name.
81+ > This is used to provide a query for looking up a domain.
82+ > The question mark is replaced with the appropriate data.
83+ > For the domain it would be the right hand side of the SMTP address.
84+ > This expects one VARCHAR to be returned with a matching domain name.
8685
8786** query\_ mailaddrmap**
8887* SQL statement*
8988
90- > This is used to provide a query to look up senders. The question mark
91- > is replaced with the appropriate data. This expects one VARCHAR to be
92- > returned with the address the sender is allowed to send mails from.
89+ > This is used to provide a query to look up senders.
90+ > The question mark is replaced with the appropriate data.
91+ > This expects one VARCHAR to be returned with the address the sender
92+ > is allowed to send mails from.
9393
9494A generic SQL statement would be something like:
9595
9696 query_ SELECT value FROM table WHERE key=$1;
9797
98+ # FILES
99+
100+ * /etc/mail/postgres.conf*
101+
102+ > Default
103+ > table-postgresql(5)
104+ > configuration file.
105+
98106# EXAMPLES
99107
100108## GENERIC EXAMPLE
@@ -104,14 +112,15 @@ The filtering part is excluded in this example.
104112
105113The configuration below is for a medium-size mail server which handles
106114multiple domains with multiple virtual users and is based on several
107- assumptions. One is that a single system user named vmail is used for all
108- virtual users. This user needs to be created:
115+ assumptions.
116+ One is that a single system user named vmail is used for all virtual users.
117+ This user needs to be created:
109118
110119 # useradd -g =uid -c "Virtual Mail" -d /var/vmail -s /sbin/nologin vmail
111120 # mkdir /var/vmail
112121 # chown vmail:vmail /var/vmail
113122
114- * PostgreSQL schema*
123+ PostgreSQL schema:
115124
116125 CREATE TABLE domains (
117126 id SERIAL,
@@ -127,6 +136,9 @@ virtual users. This user needs to be created:
127136 email VARCHAR(255) NOT NULL DEFAULT '',
128137 password VARCHAR(255) NOT NULL DEFAULT ''
129138 );
139+
140+ That can be populated as follows:
141+
130142 INSERT INTO domains VALUES (1, "example.com");
131143 INSERT INTO domains VALUES (2, "example.net");
132144 INSERT INTO domains VALUES (3, "example.org");
@@ -163,21 +175,13 @@ virtual users. This user needs to be created:
163175
164176* /etc/mail/postgres.conf*
165177
166- conninfo host='db.example.com' user='postfix' password='PostfixOutOpenSMTPDin ' dbname='postfix'
178+ conninfo host='db.example.com' user='postfix' password='... ' dbname='postfix'
167179 query_alias SELECT destination FROM alias WHERE email=$1;
168180 query_credentials SELECT username, password FROM mailbox WHERE username=$1;
169181 query_domain SELECT domain FROM domain WHERE domain=$1;
170182
171183The rest of the config remains the same.
172184
173- # FILES
174-
175- * /etc/mail/postgres.conf*
176-
177- > Default
178- > table-postgresql(8)
179- > configuration file.
180-
181185# TODO
182186
183187Documenting the following query options:
@@ -190,10 +194,10 @@ Documenting the following query options:
190194
191195# SEE ALSO
192196
197+ encrypt(1),
198+ crypt(3),
193199smtpd.conf(5),
194200smtpctl(8),
195- smtpd(8),
196- encrypt(1),
197- crypt(3)
201+ smtpd(8)
198202
199203Nixpkgs - September 30, 2016
0 commit comments