<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Alain M. Lafon &#187; Mailinglists</title> <atom:link href="http://blog.dispatched.ch/tag/mailinglists/feed/" rel="self" type="application/rss+xml" /><link>http://blog.dispatched.ch</link> <description>code, life and struggles thereof</description> <lastBuildDate>Mon, 16 Jan 2012 13:44:17 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Postfix and MySQL (Debian)</title><link>http://blog.dispatched.ch/2008/10/04/postfix-and-mysql-debian/</link> <comments>http://blog.dispatched.ch/2008/10/04/postfix-and-mysql-debian/#comments</comments> <pubDate>Sat, 04 Oct 2008 16:22:13 +0000</pubDate> <dc:creator>Alain M. Lafon</dc:creator> <category><![CDATA[articles]]></category> <category><![CDATA[installation]]></category> <category><![CDATA[Mailinglist]]></category> <category><![CDATA[Mailinglists]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[Postfix]]></category> <guid
isPermaLink="false">http://gefechtsdienst.de/?p=102</guid> <description><![CDATA[Integration of Databases in the Postfix SMTP server in Debian GNU/Linux Why would somebody want to let postfix connect to a SQL-database? There&#8217;s no need to create a real local user for each e-mail account SQL-databases can be kept in RAM, so if you have excessive mailing on your server, there will be reduced harddisk [...]]]></description> <content:encoded><![CDATA[<p>Integration of Databases in the Postfix SMTP server in Debian GNU/Linux</p><p>Why would somebody want to let postfix connect to a SQL-database?</p><ul><li> There&#8217;s no need to create a real local user for each e-mail account</li><li> SQL-databases can be kept in RAM, so if you have excessive mailing<br
/> on your server, there will be reduced harddisk access</li><li> Management of mailinglists becomes real easy</li><li> /etc/aliases is kept small and simple</li></ul><p><strong> Step 1</strong><br
/> Install the package &#8220;mysql-server&#8221;  and &#8220;mysql-client&#8221; if not yet installed.<br
/> Log on to your sql-server using the root account:</p><pre class="box">mysql --user root
mysql&gt; create database postfix_database;
mysql&gt; GRANT ALL PRIVILEGES ON postfix_database \
TO 'postfix'-AT-'localhost' IDENTIFIED BY 'postfix_password' \
WITH GRANT OPTION;
mysql&gt; flush privileges;
mysql&gt; create table postfix.postfix_alias (destination VARCHAR(50), \
alias VARCHAR(50));
mysql&gt; exit;</pre><p>Now we have created a database called &#8220;postfix_database&#8221; and a user called<br
/> &#8220;postfix&#8221; who has access to it using his unique password &#8220;postfix_password&#8221;.<br
/> With &#8220;flush privileges&#8221; we bring the sql-server up to date concerning user rights.<br
/> Then we create a table called &#8220;postfix_alias&#8221; in the database &#8220;postfix&#8221; with two rows:<br
/> &#8220;destination&#8221; is a text variable where the mail will be relayed to and &#8220;alias&#8221; is the name<br
/> of the mailinglist in my example.</p><p><strong> Step 2 </strong><br
/> Install the package &#8220;postfix-mysql&#8221;. Besides the needed<br
/> library this will bring you the config file &#8220;/etc/postfix/mysql-aliases.cf&#8221; which we<br
/> will modify like this</p><pre class="box">user = postfix
password = postfix_password
table = postfix_alias
query =  SELECT destination FROM postfix_alias WHERE alias = '%s'
hosts = unix:/var/run/mysqld/mysqld.sock
select_field = destination
where_field = alias</pre><p>Since postfix runs in a chroot it lacks several information it needs to have;<br
/> for example the socket to the mysql daemon. That&#8217;s why we provide it<br
/> with some bind mounts, which can be done by inserting these lines into<br
/> &#8220;/etc/fstab&#8221;.</p><pre class="box">/etc/passwd     /var/spool/postfix/etc/passwd           none bind 0 0
/etc/shadow     /var/spool/postfix/etc/shadow           none bind 0 0
/etc/group      /var/spool/postfix/etc/group            none bind 0 0
/var/run/mysqld /var/spool/postfix/var/run/mysqld       none bind 0 0</pre><p>To update this information the root user has to remount all filesystems<br
/> using &#8220;mount -a&#8221;.</p><p><strong>Step 3</strong><br
/> We&#8217;re done already(almost). All that is still needed is some information in the database.<br
/> Single entries can be made with the mysql client like this:</p><pre class="box">mysql&gt; insert into postfix_alias values \
('someone-AT-somewhere-DOT-de', 'mailinglistname');</pre><p>Now if you send a mail to &#8220;mailinglistname-AT-yourhost-DOT-com&#8221; the mail will be relayed to<br
/> &#8220;someone@somewhere-DOT-de&#8221;. That&#8217;s it.<br
/> I wrote a JSP/Servlet combination in JavaEE to create a webpage where users can<br
/> put themselves on or off a  mailinglist; you can find it<br
/> <a
href="http://www.gefechtsdienst.de/preek/Projects/Mailinglist/" class="broken_link">here</a> or in the<br
/> projects folder if you&#8217;re interested.</p><p><strong>Step 4</strong></p><p>Note that installing the package postfix-mysql updated a line in your &#8220;/etc/postfix/main.cf&#8221;:</p><pre class="box">alias_maps = hash:/etc/aliases
...
alias_maps = mysql:/etc/postfix/mysql-aliases.cf</pre><p>There are most likely many more lines in this file, but the important factor is<br
/> that the first line mapping to &#8220;/etc/aliases&#8221; is made obsolete by the second entry.<br
/> So if you were using some important relaying in this file you should migrate it.<br
/> For this reason I wrote a small <a
href="http://blog.dispatched.ch/daten/aliases2sql" class="broken_link"><br
/> shellscript</a> that was capable to do the job for my setup.</p> ]]></content:encoded> <wfw:commentRss>http://blog.dispatched.ch/2008/10/04/postfix-and-mysql-debian/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              44184
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: blog.dispatched.ch @ 2012-02-10 15:25:22 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: basic
Cache key:          w3tc_blog.dispatched.ch_1_page_83dcae32ebd71f7785d3805fe9c9689f_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.445s
Header info:
ETag:               "274915380f43058ea86f113a32d41d8b"
Last-Modified:      Mon, 16 Jan 2012 13:44:17 GMT
Vary:               Accept-Encoding, Cookie
X-Powered-By:       W3 Total Cache/0.9.2.4
Content-Encoding:   gzip
X-Pingback:         http://blog.dispatched.ch/xmlrpc.php
Content-Type:       text/xml; charset=UTF-8
-->
