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