1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 3 4<html> 5 6<head> 7 8<title>Postfix SQLite Howto</title> 9 10<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 11<link rel='stylesheet' type='text/css' href='postfix-doc.css'> 12 13</head> 14 15<body> 16 17<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix SQLite Howto</h1> 18 19<hr> 20 21<h2>Introduction</h2> 22 23<p> The Postfix sqlite map type allows you to hook up Postfix to a 24SQLite database. This implementation allows for multiple sqlite 25databases: you can use one for a <a href="virtual.5.html">virtual(5)</a> table, one for an 26<a href="access.5.html">access(5)</a> table, and one for an <a href="aliases.5.html">aliases(5)</a> table if you want. </p> 27 28<h2>Building Postfix with SQLite support</h2> 29 30<p> The Postfix SQLite client utilizes the sqlite3 library, 31which can be obtained from: </p> 32 33<blockquote> 34 <p> <a href="http://www.sqlite.org/">http://www.sqlite.org/</a> </p> 35</blockquote> 36 37<p> In order to build Postfix with sqlite map support, you will 38need to add to CCARGS the flags -DHAS_SQLITE and -I with the directory 39containing the sqlite header files, and you will need to add to 40AUXLIBS the directory and name of the sqlite3 library, plus the 41name of the standard POSIX thread library (pthread). For example: 42</p> 43 44<blockquote> 45<pre> 46make -f Makefile.init makefiles \ 47 "CCARGS=-DHAS_SQLITE -I/usr/local/include" \ 48 "<a href="SQLITE_README.html">AUXLIBS_SQLITE</a>=-L/usr/local/lib -lsqlite3 -lpthread" 49</pre> 50</blockquote> 51 52<p> If your SQLite shared library is in a directory that the RUN-TIME 53linker does not know about, add a "-Wl,-R,/path/to/directory" option after 54"-lsqlite3". </p> 55 56<p> Postfix versions before 3.0 use AUXLIBS instead of <a href="SQLITE_README.html">AUXLIBS_SQLITE</a>. 57With Postfix 3.0 and later, the old AUXLIBS variable still supports 58building a statically-loaded SQLite database client, but only the new 59<a href="SQLITE_README.html">AUXLIBS_SQLITE</a> variable supports building a dynamically-loaded or 60statically-loaded SQLite database client. </p> 61 62<blockquote> 63 64<p> Failure to use the <a href="SQLITE_README.html">AUXLIBS_SQLITE</a> variable will defeat the purpose 65of dynamic database client loading. Every Postfix executable file 66will have SQLITE database library dependencies. And that was exactly 67what dynamic database client loading was meant to avoid. </p> 68 69</blockquote> 70 71<p> Then, just run 'make'.</p> 72 73<h2>Using SQLite tables</h2> 74 75<p> Once Postfix is built with sqlite support, you can specify a 76map type in <a href="postconf.5.html">main.cf</a> like this: </p> 77 78<blockquote> 79<pre> 80<a href="postconf.5.html#alias_maps">alias_maps</a> = <a href="sqlite_table.5.html">sqlite</a>:/etc/postfix/sqlite-aliases.cf 81</pre> 82</blockquote> 83 84<p> The file /etc/postfix/sqlite-aliases.cf specifies lots of 85information telling Postfix how to reference the sqlite database. 86For a complete description, see the <a href="sqlite_table.5.html">sqlite_table(5)</a> manual page. </p> 87 88<h2>Example: local aliases </h2> 89 90<pre> 91# 92# sqlite config file for <a href="local.8.html">local(8)</a> <a href="aliases.5.html">aliases(5)</a> lookups 93# 94 95# Path to database 96dbpath = /some/path/to/sqlite_database 97 98# See <a href="sqlite_table.5.html">sqlite_table(5)</a> for details. 99query = SELECT forw_addr FROM mxaliases WHERE alias='%s' AND status='paid' 100</pre> 101 102<h2>Credits</h2> 103 104<p> SQLite support was added with Postfix version 2.8. </p> 105 106<ul> 107 108<li>Implementation by Axel Steiner</li> 109<li>Documentation by Jesus Garcia Crespo</li> 110 111</ul> 112 113</body> 114 115</html> 116