<?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>David Goodwin &#187; linux howto</title>
	<atom:link href="http://codepoets.co.uk/tag/linux-howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepoets.co.uk</link>
	<description>PHP, running, family stuff, Bromsgrove and other bits</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:50:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Postfixadmin &#8211; setup/install guide for virtual mail users on Postfix</title>
		<link>http://codepoets.co.uk/2009/postfixadmin-setupinstall-guide-for-virtual-mail-users-on-postfix/</link>
		<comments>http://codepoets.co.uk/2009/postfixadmin-setupinstall-guide-for-virtual-mail-users-on-postfix/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 09:11:10 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux howto]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[postfixadmin]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=14</guid>
		<description><![CDATA[This is a re-hash of the various guides I&#8217;ve made over the years detailing how to setup a virtual mail server (i.e. one that can handle multiple domains/users).
This guide is based on release 2.3 of Postfixadmin. It&#8217;s about the only open source project I contribute to regularly &#8211; so I ought to at least make [...]]]></description>
			<content:encoded><![CDATA[<p>This is a re-hash of the various guides I&#8217;ve made over the years detailing how to setup a virtual mail server (i.e. one that can handle multiple domains/users).</p>
<p>This guide is based on release 2.3 of <a title="Postfixadmin website" href="http://postfixadmin.sf.net">Postfixadmin</a>. It&#8217;s about the only open source project I contribute to regularly &#8211; so I ought to at least make an effort and document it <img src='http://codepoets.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>Requirements:</h2>
<ul>
<li>Linux Server (<a title="Debian" href="http://debian.org">Debian</a>, <a title="Ubuntu" href="http://ubuntu.com">Ubuntu</a>, CentOS, SuSE) or FreeBSD etc</li>
<li><a title="PostgreSQL" href="http://postgresql.org">PostgreSQL</a> or <a title="MySQL" href="http://mysql.com">MySQL</a> database</li>
<li><a title="PHP" href="http://php.net">PHP</a> 5.2.x or greater</li>
<li><a title="Postfix" href="http://postfix.org">Postfix</a></li>
<li>Courier / Cyrus / Dovecot (as appropriate) (I only use Courier, so am of little help with the others).</li>
</ul>
<h2>Postfixadmin Installation</h2>
<p>This assumes version 2.3 or above.</p>
<p>dpkg -i postfixadmin-xxxxx.deb</p>
<p>There are also rpm&#8217;s around somewhere for SuSE/RH, a port in FreeBSD or you can install from source.</p>
<p>Using the .deb, the database should be created for you, along with some configuration options being filled in within config.inc.php.</p>
<ol>
<li>Visit setup.php &#8211; it will prompt you to create a setup_password, which needs putting into the config.inc.php file</li>
<li>After editing config.inc.php, re-visit setup.php and follow it through &#8211; this will create the admin user and setup the initial DB structure</li>
<li>Your database should now be installed</li>
<li>You may wish to edit other config.inc.php settings (e.g. to turn vacation support on/off or to turn xmlrpc support on/off).</li>
</ol>
<p>If you perform an upgrade of Postfixadmin in the future, all upgrades to the database should be handled automatically through use of &#8216;upgrade.php&#8217;.</p>
<h2>Postfix configuration</h2>
<p>There are a few changes that need making to Postfix, firstly &#8211; it&#8217;s necessary to tell it to use a relational database for various lookups (e.g. aliases and mailboxes); it&#8217;s also necessary to configure it to support vacation/auto-reply emails &#8211; if you require this functionality.</p>
<p>In my case, I run Postfix on Debian Lenny &#8211; other platforms may vary slightly. To attempt at being &#8216;tidy&#8217; the configuration files for PostgreSQL live in /etc/postfix/pgsql.</p>
<p>(If you&#8217;re security concious, then you might want to ensure the database &#8216;postfix&#8217; user only has read permissions)</p>
<p>Note: I&#8217;ve not used the proper alias domains stuff yet &#8211; if you wish to use it, check the supplied documentation with Postfixadmin (POSTFIX_CONF.txt)</p>
<p>File: <strong>relay_domains.cf</strong></p>
<pre>user = postfix</pre>
<pre>password = something</pre>
<pre>hosts = localhost</pre>
<pre>dbname = postfix</pre>
<pre>query = SELECT domain FROM domain WHERE domain='%s' and backupmx = true</pre>
<p>File: <strong>virtual_alias_maps.cf</strong></p>
<pre>user = postfix</pre>
<pre>password = something</pre>
<pre>hosts = localhost</pre>
<pre>dbname = postfix</pre>
<pre>query = SELECT goto FROM alias WHERE address='%s' AND active = true</pre>
<p>File: <strong>virtual_domains_maps.cf</strong></p>
<pre>user = postfix</pre>
<pre>password = something</pre>
<pre>hosts = localhost</pre>
<pre>dbname = postfix</pre>
<pre>#query = SELECT domain FROM domain WHERE domain='%s'</pre>
<pre>#optional query to use when relaying for backup MX</pre>
<pre>query = SELECT domain FROM domain WHERE domain='%s' and backupmx = false and active = true</pre>
<p>File:<strong> virtual_mailbox_limits.cf</strong></p>
<pre># Used for QUOTA!</pre>
<pre>user = postfix</pre>
<pre>password = something
hosts = localhost</pre>
<pre>dbname = postfix
query = SELECT quota FROM mailbox WHERE username='%s'</pre>
<p>(Note: I&#8217;ve never used quota support, so I can&#8217;t guarantee the above is correct)</p>
<p>File: <strong>virtual_mailbox_maps.cf</strong></p>
<pre>user = postfix
password = something
hosts = localhost
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = true</pre>
<p>To <strong>/etc/postfix/main.cf </strong>add the following :</p>
<pre>relay_domains = &lt;whatever may have been here before&gt; proxy:pgsql:/etc/postfix/pgsql/relay_domains.cf
virtual_alias_maps = proxy:pgsql:/etc/postfix/pgsql/virtual_alias_maps.cf
virtual_mailbox_domains = proxy:pgsql:/etc/postfix/pgsql/virtual_domains_maps.cf
virtual_mailbox_maps = proxy:pgsql:/etc/postfix/pgsql/virtual_mailbox_maps.cf
virtual_mailbox_base = /var/mail/vmail
virtual_mailbox_limit = 512000000
virtual_minimum_uid = 8
virtual_transport = virtual
virtual_uid_maps = static:8
virtual_gid_maps = static:8
local_transport = virtual
local_recipient_maps = $virtual_mailbox_maps
# this is only needed if you want vacation support -
transport_maps = hash:/etc/postfix/transport

Adding the 'proxy:' to the various lookup lines should improve performance/scalability.</pre>
<h2>Courier configuration</h2>
<p>Courier needs configuring to know how to authorise clients and where to find mailboxes on disk.</p>
<p>/etc/courier/authdaemonrc :</p>
<p>- Enable the appropriate module &#8211; e.g.</p>
<p>authmodulelist=&#8221;authpgsql&#8221;</p>
<p>And then in &#8216;authpgsqlrc&#8217; contains :</p>
<p>PGSQL_HOST        localhost<br />
PGSQL_PORT        5432<br />
PGSQL_USERNAME        postfix<br />
PGSQL_PASSWORD        something<br />
PGSQL_DATABASE         postfix<br />
PGSQL_USER_TABLE    mailbox<br />
PGSQL_CRYPT_PWFIELD    password<br />
PGSQL_UID_FIELD        &#8217;8&#8242;<br />
PGSQL_GID_FIELD        &#8217;8&#8242;<br />
PGSQL_LOGIN_FIELD    username<br />
PGSQL_HOME_FIELD    &#8217;/var/mail/vmail&#8217;<br />
PGSQL_NAME_FIELD    name<br />
PGSQL_MAILDIR_FIELD    maildir<br />
PGSQL_QUOTA_FIELD    quota</p>
<p>(As you can see, I&#8217;ve elected to store the mail under /var/mail/vmail with file ownerships set to 8:8. Your installation may differ &#8211; but obviously ensure this is kept in sync with Postfix&#8217;s main.cf).</p>
<p>This would probably be a good time to test the system to ensure authentication works correctly &#8211; create a virtual mailbox through Postfixadmin and tail -f /var/log/mail.log and see if you can login via pop3/imap etc.</p>
<h2>SMTP Authentication</h2>
<p>This is often useful to allow remote clients to relay through the server &#8211; assuming they can prove who they are!</p>
<p>Postfix can use SASL for authentication  &#8211; this requires SASL to be told to use imap to perform the authentication checks.</p>
<p>File: /etc/sasl/smtpd.conf<br />
pwcheck_method: saslauthd<br />
saslauthd_path: /var/run/saslauthd/mux<br />
log_level: 3<br />
mech_list: PLAIN LOGIN<br />
auxprop_plugin: rimap</p>
<p>On Debian, I have sasl2-bin, libsasl2-modules and libsasl7 packages installed.</p>
<p>You&#8217;ll need to edit <strong>/etc/default/saslauthd</strong> and ensure it has :</p>
<p>OPTIONS=&#8221;-c -r  -O localhost -m /var/spool/postfix/var/run/saslauthd&#8221;</p>
<p>You may also need to explicitly create the above path.</p>
<p>Create /etc/postfix/sasl/smtpd.conf with :</p>
<pre>pwcheck_method: saslauthd</pre>
<pre>saslauthd_path: /var/run/saslauthd/mux</pre>
<pre>log_level: 3</pre>
<pre>mech_list: PLAIN LOGIN</pre>
<pre>auxprop_plugin: rimap</pre>
<p>And ensure /etc/postfix/main.cf has :</p>
<pre>smtpd_sasl_authenticated_header = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes</pre>
<p>And smtpd_sender_restrictions contains &#8216;permit_sasl_authenticated&#8217;</p>
<h2>Squirrelmail-postfixadmin</h2>
<p>If you wish to allow your users to change their passwords/forwarding settings or vacation/auto-reply settings, a postfixadmin plugin is available for squirrelmail (squirrelmail-postfixadmin). You can download it from <a title="Squirrelmail Postfixadmin plugin" href="http://squirrelmail-postfixadmin.palepurple.co.uk">http://squirrelmail-postfixadmin.palepurple.co.uk</a>.</p>
<p>The latest version of the plugin works over XMLRPC and requires very minimal configuration &#8211; you&#8217;ll need to edit the config file within the plugin to specify the XMLRPC interface URL (http://server/postfixadmin/xmlrpc.php). It&#8217;s also necessary to edit the Postfixadmin config.inc.php file to explicitly enable the xmlrpc interface.</p>
<p>Note, when your users go to use the postfixadmin-squirrelmail plugin they will be prompted to enter their mailbox password.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2009/postfixadmin-setupinstall-guide-for-virtual-mail-users-on-postfix/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
