<?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>johker&#039;s blog &#187; 993</title>
	<atom:link href="http://johker.ibutho.de/tag/993/feed/" rel="self" type="application/rss+xml" />
	<link>http://johker.ibutho.de</link>
	<description>stories about me, my life and my trips</description>
	<lastBuildDate>Sun, 18 Dec 2011 11:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Der neue Server: Teil 5 postfix</title>
		<link>http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/</link>
		<comments>http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 21:41:30 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[110]]></category>
		<category><![CDATA[143]]></category>
		<category><![CDATA[2000]]></category>
		<category><![CDATA[993]]></category>
		<category><![CDATA[995]]></category>
		<category><![CDATA[abuse.net]]></category>
		<category><![CDATA[anti-stasi]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[create role]]></category>
		<category><![CDATA[create user]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[deliver]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[dovecot postgres integration]]></category>
		<category><![CDATA[dovecot-deliver.log]]></category>
		<category><![CDATA[dovecot-imapd]]></category>
		<category><![CDATA[dovecot-pop3d]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[imaps]]></category>
		<category><![CDATA[lda]]></category>
		<category><![CDATA[mail server]]></category>
		<category><![CDATA[maildir]]></category>
		<category><![CDATA[main.cf]]></category>
		<category><![CDATA[managesieve]]></category>
		<category><![CDATA[master.cf]]></category>
		<category><![CDATA[mda]]></category>
		<category><![CDATA[microsoft sucks]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[mx_access]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[pcre]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pop3]]></category>
		<category><![CDATA[pop3s]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[postfixadmin]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[quota]]></category>
		<category><![CDATA[recipient_checks]]></category>
		<category><![CDATA[relay_domains]]></category>
		<category><![CDATA[restrictions]]></category>
		<category><![CDATA[sasl]]></category>
		<category><![CDATA[sieve]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[smtps]]></category>
		<category><![CDATA[sql queries]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[tls]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[virtual hosting]]></category>
		<category><![CDATA[virtual_alias_maps]]></category>
		<category><![CDATA[virtual_mailbox_domains]]></category>
		<category><![CDATA[virtual_mailbox_maps]]></category>
		<category><![CDATA[virtual_transport]]></category>
		<category><![CDATA[webinterface]]></category>
		<category><![CDATA[workarounds]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=165</guid>
		<description><![CDATA[Hier wird erklärt wie man postfix mit postgreSQL-Backend installiert, dovecot inkl. sieve konfiguriert, sowie postfixadmin einrichtet, um postfix bequem über ein Webinterface verwalten zu können. Datenbank anlegen Als Erstes legen wir einen Datenbankbenutzer inkl. Datenbank für postfix an: su - &#8230; <a href="http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hier wird erklärt wie man <em>postfix</em> mit postgreSQL-Backend installiert, <em>dovecot</em> inkl. <em>sieve</em> konfiguriert, sowie <em>postfixadmin</em> einrichtet, um <em>postfix</em> bequem über ein Webinterface verwalten zu können.</p>
<h1>Datenbank anlegen</h1>
<p>Als Erstes legen wir einen Datenbankbenutzer inkl. Datenbank für <em>postfix</em> an:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
psql template1
CREATE USER postfix WITH PASSWORD <span style="color: #ff0000;">'password'</span>;
CREATE DATABASE postfix WITH OWNER postfix ENCODING <span style="color: #ff0000;">'UNICODE'</span>;
\q</pre></div></div>

<h1>Verzeichnis anlegen</h1>
<p>Später werden alle Mailboxen unter &#8220;<em>/var/vmail/DOMAIN/BENUTZERNAME/maildir/</em>&#8221; liegen, deshalb erstellen wir nun den Ordner &#8220;<em>/var/vmail</em>&#8221; und vergeben entsprechende Rechte. Die Einsortierung nach &#8220;<em>/var/vmail/DOMAIN/BENUTZERNAME/maildir/</em>&#8221; geschieht später über SQL-Queries automatisch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">useradd <span style="color: #660033;">-r</span> <span style="color: #660033;">-u</span> <span style="color: #000000;">150</span> <span style="color: #660033;">-g</span> mail <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nologin <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'Virtual mailbox'</span> vmail
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">770</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> vmail:mail <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<h1>postfixadmin</h1>
<p><em>postfixadmin</em> installieren wir direkt aus deren <em>svn</em>-Repository, um mit der aktuellste Version zu arbeiten. Sollte es zu Problemen kommen, kann man über <a href="http://postfixadmin.sourceforge.net/" target="_blank">http://postfixadmin.sourceforge.net/</a> die neueste stabile Version herunterladen.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> https:<span style="color: #000000; font-weight: bold;">//</span>postfixadmin.svn.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>svnroot<span style="color: #000000; font-weight: bold;">/</span>postfixadmin<span style="color: #000000; font-weight: bold;">/</span>trunk postfixadmin-svn
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> postfixadmin-svn postfixadmin</pre></div></div>

<p>Danach passt man die Konfigurationsdatei &#8220;<em>/var/www/postfixadmin/config.inc.php</em>&#8221; an seine Wünsche und Anforderungen an. Nach Ausführen des &#8220;setup.php&#8221;-Skripts im Browser (und anschließendem Löschen/Umbenennen) ist <em>postfixadmin</em> einsatzbereit.</p>
<h1>postfix</h1>
<p><em>postfix</em> installieren:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> postfix postfix-pgsql postfix-pcre</pre></div></div>

<p>Während der Installation von <em>postfix</em> wird man gefragt, wie man <em>postfix</em> konfigurieren will, dort wählt man &#8220;<strong>Internet Site</strong>&#8221; aus (wobei dies später irrelevant ist, da wir die Konfiguration komplett selbst schreiben).</p>
<h2>Datenbankverbindung konfigurieren</h2>
<p>Damit <em>postfix</em> mit den Accounts, die in <em>postfixadmin</em> angelegt werden zusammenarbeitet, müssen wir verschiedene SQL-Queries anlegen:</p>
<p><em>relay-domains.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user            = postfix
password        = xxxxxxx
dbname          = postfix
hosts           = localhost
query = SELECT domain FROM domain WHERE domain = <span style="color: #ff0000;">'%s'</span> AND backupmx = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-alias-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT goto FROM <span style="color: #7a0874; font-weight: bold;">alias</span> WHERE <span style="color: #007800;">address</span>=<span style="color: #ff0000;">'%s'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-domain-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT domain FROM domain WHERE <span style="color: #007800;">domain</span>=<span style="color: #ff0000;">'%s'</span> AND backupmx = <span style="color: #c20cb9; font-weight: bold;">false</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-mailbox-limit-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT quota FROM mailbox WHERE username = <span style="color: #ff0000;">'%s'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-mailbox-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT maildir <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'maildir'</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'/'</span> FROM mailbox WHERE <span style="color: #007800;">username</span>=<span style="color: #ff0000;">'%s'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<h2>recipient checks</h2>
<p>Mit <em>recipient checks</em> kann man E-Mailadressen anhand von regulären Ausdrücken prüfen und dadurch Mails entweder annehmen oder ablehnen. Hier werden invalide E-Mailadressen, bzw. welche mit &#8220;seltsamer&#8221; Syntax abgewiesen und E-Mails an postmaster, hostmaster, webmaster und abuse immer angenommen.</p>
<p><em>/etc/postfix/recipient_checks.pcre</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>^\<span style="color: #000000; font-weight: bold;">@/</span>             <span style="color: #000000;">550</span> Invalid address format.
<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">!%</span>\<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>.<span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #000000; font-weight: bold;">@/</span>      <span style="color: #000000;">550</span> This server disallows weird address syntax.
<span style="color: #000000; font-weight: bold;">/</span>^postmaster\<span style="color: #000000; font-weight: bold;">@/</span>   OK
<span style="color: #000000; font-weight: bold;">/</span>^hostmaster\<span style="color: #000000; font-weight: bold;">@/</span>   OK
<span style="color: #000000; font-weight: bold;">/</span>^webmaster\<span style="color: #000000; font-weight: bold;">@/</span>    OK
<span style="color: #000000; font-weight: bold;">/</span>^abuse\<span style="color: #000000; font-weight: bold;">@/</span>        OK</pre></div></div>

<h2>mx access</h2>
<p>Über diese Datei werden E-Mails von Gegenstellen aus privaten IP-Blöcken, bzw. von Broadcast- und Multicast-Netzen von vorneherein abgewiesen, da diese im Internet prinzipiell nicht geroutet werden und es sich dabei mit extrem hoher Wahrscheinlichkeit um Spam handelt.</p>
<p><em>/etc/postfix/mx_access</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>         REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> broadcast network
10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>        REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> RFC <span style="color: #000000;">1918</span> private network
127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> loopback network
169.254.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span>    REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #c20cb9; font-weight: bold;">link</span> <span style="color: #7a0874; font-weight: bold;">local</span> network
172.16.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span>     REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> RFC <span style="color: #000000;">1918</span> private network
192.0.2.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span>      REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> TEST-NET network
192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span>    REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> RFC <span style="color: #000000;">1918</span> private network
224.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> class D multicast network
240.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> class E reserved network
248.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> reserved network</pre></div></div>

<p>Nun muss daraus noch eine <em>postfix-lookup table</em> erstellt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">postmap <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mx_access</pre></div></div>

<h2>main.cf</h2>
<p>Nun müssen wir noch <em>postfix</em> konfigurieren und alle Teilkonfigurationen, die wir gerade erstellt haben zusammenfügen. Dies geschieht über die Datei &#8220;<em>/etc/postfix/main.cf</em>&#8220;:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># -------------------- GENERAL PART START --------------------</span>
allow_percent_hack = no
biff = no
disable_vrfy_command = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
mydestination = <span style="color: #007800;">$myhostname</span>, <span style="color: #007800;">$mydomain</span>, localhost
mydomain = domain.tld
myhostname = mail.domain.tld
mynetworks_style = host
myorigin = <span style="color: #007800;">$mydomain</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#home_mailbox = Maildir/</span>
<span style="color: #666666; font-style: italic;">#mailbox_size_limit = 2147483648</span>
<span style="color: #666666; font-style: italic;">#message_size_limit = 209715200</span>
local_transport = dovecot
masquerade_exceptions = root
recipient_delimiter = +
<span style="color: #666666; font-style: italic;"># -------------------- GENERAL PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- VIRTUAL PART START --------------------</span>
virtual_mailbox_base = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail
relay_domains = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>relay-domain-maps.cf
virtual_mailbox_maps = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>virtual-mailbox-maps.cf
virtual_mailbox_domains = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>virtual-domain-maps.cf
virtual_alias_maps = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>virtual-alias-maps.cf
virtual_minimum_uid = <span style="color: #000000;">150</span>
virtual_uid_maps = static:<span style="color: #000000;">150</span>
virtual_gid_maps = static:<span style="color: #000000;">8</span>
virtual_transport = dovecot
dovecot_destination_recipient_limit = <span style="color: #000000;">1</span>
unknown_local_recipient_reject_code = <span style="color: #000000;">550</span>
<span style="color: #666666; font-style: italic;"># -------------------- VIRTUAL PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- RESTRICTIONS PART START --------------------</span>
smtpd_delay_reject = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_helo_required = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
smtpd_client_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unknown_reverse_client_hostname,
  permit
smtpd_data_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unauth_pipelining,
  permit
smtpd_helo_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_invalid_helo_hostname,
  reject_non_fqdn_helo_hostname,
  permit
smtpd_recipient_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_non_fqdn_recipient,
  reject_unknown_recipient_domain,
  check_recipient_mx_access cidr:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mx_access,
  reject_unauth_destination,
  check_recipient_access pcre:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>recipient_checks.pcre,
<span style="color: #666666; font-style: italic;">###  check_policy_service inet:127.0.0.1:12525,</span>
  permit
smtpd_sender_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_non_fqdn_sender,
  reject_unknown_sender_domain,
  permit
<span style="color: #666666; font-style: italic;"># -------------------- RESTRICTIONS PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- SASL PART START --------------------</span>
broken_sasl_auth_clients = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_sasl_auth_enable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_sasl2_auth_enable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_sasl_local_domain = 
smtpd_sasl_type = dovecot
smtpd_sasl_path = private<span style="color: #000000; font-weight: bold;">/</span>auth
<span style="color: #666666; font-style: italic;"># -------------------- SASL PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- TLS PART START --------------------</span>
smtpd_use_tls = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_tls_security_level = may
<span style="color: #666666; font-style: italic;">#smtpd_tls_auth_only = yes</span>
smtpd_tls_CAfile = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>demoCA<span style="color: #000000; font-weight: bold;">/</span>cacert.pem
smtpd_tls_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>server-crt.pem
smtpd_tls_dh1024_param_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>dh_1024.pem
smtpd_tls_dh512_param_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>dh_512.pem
smtpd_tls_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>server-key.pem
smtpd_tls_session_cache_database = btree:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>smtpd_tls_session_cache
<span style="color: #666666; font-style: italic;"># -------------------- TLS PART END --------------------</span></pre></div></div>

<h2>master.cf</h2>
<p>Ans Ende der &#8220;<em>/etc/postfix/master.cf</em>&#8221; anhängen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Dovecot LDA</span>
dovecot unix - n n - - pipe
<span style="color: #007800;">flags</span>=DRhu <span style="color: #007800;">user</span>=vmail:mail <span style="color: #007800;">argv</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>deliver <span style="color: #660033;">-d</span> <span style="color: #800000;">${recipient}</span></pre></div></div>

<p>Will man auch <em>smtps</em> (Port 465) zulassen, so entfernt man die Raute-Zeichen vor den untenstehenden Zeilen, damit sie wie folgt aussehen (die Leerzeichen vor der zweiten Zeile sind essentiell):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">smtps     inet  n       -       -       -       -       smtpd
  <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_tls_wrappermode</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p><em>smpts</em> kann nützlich sein, wenn Port 25 aus irgend einem Grund gesperrt sein sollte, denn es operiert auf Port 465, welcher seltener gesperrt ist (zumindest in Studentenwohnheimen und Universitäten), zusätzlich bietet es einen höheren Schutz als plaintext-smtp (doch einen geringeren als smtp+tls).</p>
<h1>dovecot</h1>
<p>Nun folgt die Konfiguration des dovecot E-Mail-Servers. Zunächst wird dovecot über aptitude:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> dovecot-imapd dovecot-pop3d</pre></div></div>

<p>Jetzt wird dovecot noch konfiguriert:</p>
<p><em>/etc/dovecot/dovecot.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">## Dovecot configuration file</span>
&nbsp;
base_dir = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># imap imaps pop3 pop3s (use imaps and pop3s if configured for SSL)</span>
protocols = imaps imap pop3s pop3 managesieve
&nbsp;
<span style="color: #666666; font-style: italic;"># Uncomment the ssl_listen statements and comment out listen if using SSL</span>
protocol imap <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">143</span>
  ssl_listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">993</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol pop3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">110</span>
  ssl_listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">995</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol managesieve <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">2000</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
log_timestamp = “<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d <span style="color: #000000; font-weight: bold;">%</span>H:<span style="color: #000000; font-weight: bold;">%</span>M:<span style="color: #000000; font-weight: bold;">%</span>S ”
syslog_facility = mail
&nbsp;
<span style="color: #666666; font-style: italic;"># Where the mailboxes are located</span>
mail_location = maildir:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>maildir
mail_access_groups = vmail
mail_debug = <span style="color: #c20cb9; font-weight: bold;">yes</span>
first_valid_uid = <span style="color: #000000;">150</span>
last_valid_uid = <span style="color: #000000;">150</span>
maildir_copy_with_hardlinks = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
protocol imap <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  login_executable = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>imap-login
  mail_executable = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>imap
  imap_max_line_length = <span style="color: #000000;">65536</span>
  mail_plugins = quota imap_quota
  imap_client_workarounds = outlook-idle delay-newmail
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol pop3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  login_executable = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>pop3-login
  mail_executable = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>pop3
  pop3_uidl_format = <span style="color: #000000; font-weight: bold;">%</span>08Xu<span style="color: #000000; font-weight: bold;">%</span>08Xv
  mail_plugins = quota
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol lda <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  postmaster_address = postmaster<span style="color: #000000; font-weight: bold;">@</span>ibutho.de
  sendmail_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span>
  auth_socket_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-master
  mail_plugins = quota cmusieve
  sieve_global_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/</span>default.sieve
  log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver.log
  info_log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver.log
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol managesieve <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  sieve = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>dovecot.sieve
  sieve_storage = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>sieve
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
auth_verbose = no
auth_debug = <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;">#auth_debug_passwords = yes</span>
&nbsp;
auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 mechanisms = plain <span style="color: #c20cb9; font-weight: bold;">login</span>
&nbsp;
 passdb sql <span style="color: #7a0874; font-weight: bold;">&#123;</span>
   args = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>dovecot-sql.conf
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
 userdb sql <span style="color: #7a0874; font-weight: bold;">&#123;</span>
   args = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>dovecot-sql.conf
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
 userdb prefetch <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
 user = nobody
&nbsp;
 socket listen <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  master <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-master
    mode = 0660
    user = vmail
    group = mail
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
  client <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>auth
    mode = 0660
    user = postfix
    group = postfix
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
dict <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
plugin <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  acl = vfile:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>acls
  sieve = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>dovecot.sieve
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Uncomment these if using SSL</span>
ssl_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>ibutho_server.pem
ssl_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>ibutho_privatekey.pem
ssl_ca_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>root.pem
ssl_parameters_regenerate = <span style="color: #000000;">168</span>
verbose_ssl = no
<span style="color: #666666; font-style: italic;"># If you want client certificates, use these lines</span>
<span style="color: #666666; font-style: italic;"># ssl_verify_client_cert = yes</span>
<span style="color: #666666; font-style: italic;"># ssl_require_client_cert = yes</span>
<span style="color: #666666; font-style: italic;"># ssl_username_from_cert = yes</span></pre></div></div>

<p>Damit das logging nach &#8220;<em>/var/log/dovecot-deliver.log</em>&#8221; funktioniert, muss die Datei mit entsprechenden Rechten ausgestattet sein:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver.log
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">640</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver.log
<span style="color: #c20cb9; font-weight: bold;">chown</span> vmail:mail <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver.log</pre></div></div>

<p><em>/etc/dovecot/dovecot-sql.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">driver = pgsql
connect = <span style="color: #007800;">host</span>=localhost <span style="color: #007800;">dbname</span>=postfix <span style="color: #007800;">user</span>=postfix <span style="color: #007800;">password</span>=xxxxxxxx
default_pass_scheme = MD5
&nbsp;
user_query = SELECT <span style="color: #ff0000;">'/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir AS home, <span style="color: #ff0000;">'maildir:/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'maildir'</span> AS mail, <span style="color: #000000;">150</span> AS uid, <span style="color: #000000;">8</span> AS gid, <span style="color: #ff0000;">'maildir:storage='</span> <span style="color: #000000; font-weight: bold;">||</span> quota AS quota FROM mailbox WHERE local_part = split_part<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'%n'</span>, <span style="color: #ff0000;">'+'</span>, <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> AND domain = <span style="color: #ff0000;">'%d'</span>  AND active = <span style="color: #c20cb9; font-weight: bold;">true</span>
&nbsp;
password_query = SELECT username AS user, password, <span style="color: #ff0000;">'/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir AS userdb_home, <span style="color: #ff0000;">'maildir:/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'maildir'</span> AS userdb_mail, <span style="color: #000000;">150</span> <span style="color: #c20cb9; font-weight: bold;">as</span> userdb_uid, <span style="color: #000000;">8</span> <span style="color: #c20cb9; font-weight: bold;">as</span> userdb_gid FROM mailbox WHERE username = <span style="color: #ff0000;">'%u'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<h1>Testen der Konfiguration</h1>
<p>Zuerst kann man serverseitig mittels &#8220;<code>netstat -tulpen</code>&#8221; testen, ob der Server auf allen beabsichtigten Ports lauscht (110, 143, 993, 995, 2000). Danach kann man mittels &#8220;<code>telnet SERVER_IP 143</code>&#8220;, bzw. &#8220;<code>telnet SERVER_IP 110</code>&#8221; testen, ob man eine Verbindung bekommt. Ist dies der Fall, bietet es sich an auszuprobieren, ob man mit einem Mailprogramm auf das Postfach zugreifen kann (es muss natürlich eins in <em>postfixadmin</em> angelegt sein), bzw. ob man auch Mails empfangen und versenden kann.<br />
Ein weiterer wichtiger Test, den man durchführen sollte, ist, ob der Mailserver als &#8220;open relay&#8221; missbraucht werden kann (kurz und knapp heißt das, ob der Server möglicherweise eine &#8220;Spam-Schleuder&#8221; ist). Dies kann man u.a. hier testen: <a href="http://www.abuse.net/relay.html" target="_blank">http://www.abuse.net/relay.html</a>. Sollten alle Tests Erfolg haben, hat man einen funktionsfähigen Mailserver.</p>
<p>Quellen:<br />
postfixadmin/DOCUMENTS/POSTFIX_CONF.txt</p>
<p>http://blog.schalanda.name/archives/178-EUserv-vServer-Active-Installation-des-Mailsystems.html</p>
<p>http://codepoets.co.uk/postfixadmin-postgresql-courier-squirrelmail-debian-etch-howto-tutorial</p>
<p>http://wiki.rootforum.de/mailserver/postfix</p>
<p>http://wiki.rootforum.de/mailserver/postfix/postfix-admin</p>
<p>http://forum.rootforum.de/viewtopic.php?f=111&#038;t=46643</p>
<p>http://www.postfix.org/postconf.5.html</p>
<p>http://wiki.dovecot.org/MainConfig</p>
<p>http://wiki.dovecot.org/ManageSieve</p>
<p>http://wiki.dovecot.org/LDA/Sieve</p>
<p>http://wiki.dovecot.org/HowTo/DovecotLDAPostfixAdminMySQL</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

