1#++ 2# NAME 3# sqlite_table 5 4# SUMMARY 5# Postfix SQLite configuration 6# SYNOPSIS 7# \fBpostmap -q "\fIstring\fB" sqlite:/etc/postfix/\fIfilename\fR 8# 9# \fBpostmap -q - sqlite:/etc/postfix/\fIfilename\fB <\fIinputfile\fR 10# DESCRIPTION 11# The Postfix mail system uses optional tables for address 12# rewriting or mail routing. These tables are usually in 13# \fBdbm\fR or \fBdb\fR format. 14# 15# Alternatively, lookup tables can be specified as SQLite databases. 16# In order to use SQLite lookups, define an SQLite source as a lookup 17# table in main.cf, for example: 18# .nf 19# alias_maps = sqlite:/etc/sqlite-aliases.cf 20# .fi 21# 22# The file /etc/postfix/sqlite-aliases.cf has the same format as 23# the Postfix main.cf file, and can specify the parameters 24# described below. 25# BACKWARDS COMPATIBILITY 26# .ad 27# .fi 28# For compatibility with other Postfix lookup tables, SQLite 29# parameters can also be defined in main.cf. In order to do that, 30# specify as SQLite source a name that doesn't begin with a slash 31# or a dot. The SQLite parameters will then be accessible as the 32# name you've given the source in its definition, an underscore, 33# and the name of the parameter. For example, if the map is 34# specified as "sqlite:\fIsqlitename\fR", the parameter "query" 35# below would be defined in main.cf as "\fIsqlitename\fR_query". 36# 37# Normally, the SQL query is specified via a single \fBquery\fR 38# parameter (described in more detail below). When this 39# parameter is not specified in the map definition, Postfix 40# reverts to an older interface, with the SQL query constructed 41# from the \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR 42# and \fBadditional_conditions\fR parameters. The old interface 43# will be gradually phased out. To migrate to the new interface 44# set: 45# 46# .nf 47# \fBquery\fR = SELECT [\fIselect_field\fR] 48# FROM [\fItable\fR] 49# WHERE [\fIwhere_field\fR] = '%s' 50# [\fIadditional_conditions\fR] 51# .fi 52# 53# Insert the value, not the name, of each legacy parameter. Note 54# that the \fBadditional_conditions\fR parameter is optional 55# and if not empty, will always start with \fBAND\fR. 56# LIST MEMBERSHIP 57# .ad 58# .fi 59# When using SQL to store lists such as $mynetworks, 60# $mydestination, $relay_domains, $local_recipient_maps, 61# etc., it is important to understand that the table must 62# store each list member as a separate key. The table lookup 63# verifies the *existence* of the key. See "Postfix lists 64# versus tables" in the DATABASE_README document for a 65# discussion. 66# 67# Do NOT create tables that return the full list of domains 68# in $mydestination or $relay_domains etc., or IP addresses 69# in $mynetworks. 70# 71# DO create tables with each matching item as a key and with 72# an arbitrary value. With SQL databases it is not uncommon to 73# return the key itself or a constant value. 74# SQLITE PARAMETERS 75# .ad 76# .fi 77# .IP "\fBdbpath\fR" 78# The SQLite database file location. Example: 79# .nf 80# dbpath = customer_database 81# .fi 82# .IP "\fBquery\fR" 83# The SQL query template used to search the database, where \fB%s\fR 84# is a substitute for the address Postfix is trying to resolve, 85# e.g. 86# .nf 87# query = SELECT replacement FROM aliases WHERE mailbox = '%s' 88# .fi 89# 90# This parameter supports the following '%' expansions: 91# .RS 92# .IP "\fB\fB%%\fR\fR" 93# This is replaced by a literal '%' character. 94# .IP "\fB\fB%s\fR\fR" 95# This is replaced by the input key. 96# SQL quoting is used to make sure that the input key does not 97# add unexpected metacharacters. 98# .IP "\fB\fB%u\fR\fR" 99# When the input key is an address of the form user@domain, \fB%u\fR 100# is replaced by the SQL quoted local part of the address. 101# Otherwise, \fB%u\fR is replaced by the entire search string. 102# If the localpart is empty, the query is suppressed and returns 103# no results. 104# .IP "\fB\fB%d\fR\fR" 105# When the input key is an address of the form user@domain, \fB%d\fR 106# is replaced by the SQL quoted domain part of the address. 107# Otherwise, the query is suppressed and returns no results. 108# .IP "\fB\fB%[SUD]\fR\fR" 109# The upper-case equivalents of the above expansions behave in the 110# \fBquery\fR parameter identically to their lower-case counter-parts. 111# With the \fBresult_format\fR parameter (see below), they expand the 112# input key rather than the result value. 113# .IP "\fB\fB%[1-9]\fR\fR" 114# The patterns %1, %2, ... %9 are replaced by the corresponding 115# most significant component of the input key's domain. If the 116# input key is \fIuser@mail.example.com\fR, then %1 is \fBcom\fR, 117# %2 is \fBexample\fR and %3 is \fBmail\fR. If the input key is 118# unqualified or does not have enough domain components to satisfy 119# all the specified patterns, the query is suppressed and returns 120# no results. 121# .RE 122# .IP 123# The \fBdomain\fR parameter described below limits the input 124# keys to addresses in matching domains. When the \fBdomain\fR 125# parameter is non-empty, SQL queries for unqualified addresses 126# or addresses in non-matching domains are suppressed 127# and return no results. 128# 129# This parameter is available with Postfix 2.2. In prior releases 130# the SQL query was built from the separate parameters: 131# \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR and 132# \fBadditional_conditions\fR. The mapping from the old parameters 133# to the equivalent query is: 134# 135# .nf 136# SELECT [\fBselect_field\fR] 137# FROM [\fBtable\fR] 138# WHERE [\fBwhere_field\fR] = '%s' 139# [\fBadditional_conditions\fR] 140# .fi 141# 142# The '%s' in the \fBWHERE\fR clause expands to the escaped search string. 143# With Postfix 2.2 these legacy parameters are used if the \fBquery\fR 144# parameter is not specified. 145# 146# NOTE: DO NOT put quotes around the query parameter. 147# .IP "\fBresult_format (default: \fB%s\fR)\fR" 148# Format template applied to result attributes. Most commonly used 149# to append (or prepend) text to the result. This parameter supports 150# the following '%' expansions: 151# .RS 152# .IP "\fB\fB%%\fR\fR" 153# This is replaced by a literal '%' character. 154# .IP "\fB\fB%s\fR\fR" 155# This is replaced by the value of the result attribute. When 156# result is empty it is skipped. 157# .IP "\fB%u\fR 158# When the result attribute value is an address of the form 159# user@domain, \fB%u\fR is replaced by the local part of the 160# address. When the result has an empty localpart it is skipped. 161# .IP "\fB\fB%d\fR\fR" 162# When a result attribute value is an address of the form 163# user@domain, \fB%d\fR is replaced by the domain part of 164# the attribute value. When the result is unqualified it 165# is skipped. 166# .IP "\fB\fB%[SUD1-9]\fR\fB" 167# The upper-case and decimal digit expansions interpolate 168# the parts of the input key rather than the result. Their 169# behavior is identical to that described with \fBquery\fR, 170# and in fact because the input key is known in advance, queries 171# whose key does not contain all the information specified in 172# the result template are suppressed and return no results. 173# .RE 174# .IP 175# For example, using "result_format = smtp:[%s]" allows one 176# to use a mailHost attribute as the basis of a transport(5) 177# table. After applying the result format, multiple values 178# are concatenated as comma separated strings. The expansion_limit 179# and parameter explained below allows one to restrict the number 180# of values in the result, which is especially useful for maps that 181# must return at most one value. 182# 183# The default value \fB%s\fR specifies that each result value should 184# be used as is. 185# 186# This parameter is available with Postfix 2.2 and later. 187# 188# NOTE: DO NOT put quotes around the result format! 189# .IP "\fBdomain (default: no domain list)\fR" 190# This is a list of domain names, paths to files, or 191# dictionaries. When specified, only fully qualified search 192# keys with a *non-empty* localpart and a matching domain 193# are eligible for lookup: 'user' lookups, bare domain lookups 194# and "@domain" lookups are not performed. This can significantly 195# reduce the query load on the SQLite server. 196# .nf 197# domain = postfix.org, hash:/etc/postfix/searchdomains 198# .fi 199# 200# It is best not to use SQL to store the domains eligible 201# for SQL lookups. 202# 203# This parameter is available with Postfix 2.2 and later. 204# 205# NOTE: DO NOT define this parameter for local(8) aliases, 206# because the input keys are always unqualified. 207# .IP "\fBexpansion_limit (default: 0)\fR" 208# A limit on the total number of result elements returned 209# (as a comma separated list) by a lookup against the map. 210# A setting of zero disables the limit. Lookups fail with a 211# temporary error if the limit is exceeded. Setting the 212# limit to 1 ensures that lookups do not return multiple 213# values. 214# OBSOLETE QUERY INTERFACE 215# .ad 216# .fi 217# This section describes an interface that is deprecated as 218# of Postfix 2.2. It is replaced by the more general \fBquery\fR 219# interface described above. If the \fBquery\fR parameter 220# is defined, the legacy parameters described here ignored. 221# Please migrate to the new interface as the legacy interface 222# may be removed in a future release. 223# 224# The following parameters can be used to fill in a 225# SELECT template statement of the form: 226# 227# .nf 228# SELECT [\fBselect_field\fR] 229# FROM [\fBtable\fR] 230# WHERE [\fBwhere_field\fR] = '%s' 231# [\fBadditional_conditions\fR] 232# .fi 233# 234# The specifier %s is replaced by the search string, and is 235# escaped so if it contains single quotes or other odd characters, 236# it will not cause a parse error, or worse, a security problem. 237# .IP "\fBselect_field\fR" 238# The SQL "select" parameter. Example: 239# .nf 240# \fBselect_field\fR = forw_addr 241# .fi 242# .IP "\fBtable\fR" 243# The SQL "select .. from" table name. Example: 244# .nf 245# \fBtable\fR = mxaliases 246# .fi 247# .IP "\fBwhere_field\fR 248# The SQL "select .. where" parameter. Example: 249# .nf 250# \fBwhere_field\fR = alias 251# .fi 252# .IP "\fBadditional_conditions\fR 253# Additional conditions to the SQL query. Example: 254# .nf 255# \fBadditional_conditions\fR = AND status = 'paid' 256# .fi 257# SEE ALSO 258# postmap(1), Postfix lookup table maintenance 259# postconf(5), configuration parameters 260# ldap_table(5), LDAP lookup tables 261# mysql_table(5), MySQL lookup tables 262# pgsql_table(5), PostgreSQL lookup tables 263# README FILES 264# .ad 265# .fi 266# Use "\fBpostconf readme_directory\fR" or 267# "\fBpostconf html_directory\fR" to locate this information. 268# .na 269# .nf 270# DATABASE_README, Postfix lookup table overview 271# SQLITE_README, Postfix SQLITE howto 272# LICENSE 273# .ad 274# .fi 275# The Secure Mailer license must be distributed with this software. 276# HISTORY 277# SQLite support was introduced with Postfix version 2.8. 278# AUTHOR(S) 279# Original implementation by: 280# Axel Steiner 281#-- 282