<?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>Linux, Programming, Telephony, Asterisk, Apache, Tips &#38; Tricks &#187; all</title>
	<atom:link href="http://shahidz.com/tag/all/feed/" rel="self" type="application/rss+xml" />
	<link>http://shahidz.com</link>
	<description>Passionate About Technology</description>
	<lastBuildDate>Sun, 10 Jan 2010 17:38:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Postfix Mail Server with catch all E-Mails</title>
		<link>http://shahidz.com/postfix-and-virtual-hosts/</link>
		<comments>http://shahidz.com/postfix-and-virtual-hosts/#comments</comments>
		<pubDate>Mon, 25 Feb 2008 10:47:14 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[all]]></category>
		<category><![CDATA[catch all]]></category>
		<category><![CDATA[catchall]]></category>
		<category><![CDATA[mail server]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[teapop]]></category>

		<guid isPermaLink="false">http://shahidz.com/?p=10</guid>
		<description><![CDATA[ Installing a mail server, using Postfix, that is based on virtual users and domains.
Introduction
Postfix has several hundred configuration parameters that are controlled via the etc&#8217;/postfix/main.cf&#8217; file. Fortunately, they have sensible default values. In most cases, you need to configure only two or three parameters before you can use the Postfix mail system:
Step 1. Installing [...]]]></description>
			<content:encoded><![CDATA[<p> Installing a mail server, using Postfix, that is based on virtual users and domains.</p>
<p style="margin-bottom: 0cm"><strong>Introduction</strong></p>
<p><span>Postfix has several hundred configuration parameters that are controlled via the etc&#8217;/postfix/main.cf&#8217; file. Fortunately, they have sensible default values. In most cases, you need to configure only two or three parameters before you can use the Postfix mail system:</span></p>
<p><strong>Step 1. Installing Postfix Mail Server<br />
</strong></p>
<pre>$ apt-get install postfix postfix-mysql</pre>
<p><strong>POSTFIX Default settings:</strong></p>
<p>There is 3 main files that need to get your attention:</p>
<ul>
<li>/etc/mailname : the visible mail name of the system</li>
<li>/etc/aliases : Postfix local alias database format</li>
<li>/etc/postfix/main.cf : Postfix configuration parameters</li>
</ul>
<p><strong>Step 2. Edit the following files</strong></p>
<p><strong>etc/mailname</strong> : This is where you set the domain name of the system, has seen by the other. <strong>It needs</strong>, in most cases, to look like a real domain name, otherwise, the next smtp server on the road might refuse the mails originating from your machine.</p>
<p>In this example, I choose  <em>debuntu.local</em>.</p>
<p><strong>/etc/aliases</strong> :<br />
The place you define aliases. For instance, it is quite good to redirect all mail to root to your normal user.</p>
<p>Add</p>
<p># Added by installer for initial user<br />
root:   myuser</p>
<p>From now on, you will be able to get system notice using mutt with your <em>myuser</em> user.</p>
<p><strong>/etc/postfix/main.cf</strong> :</p>
<p style="margin-bottom: 0.5cm"><strong>A sample main.cf file</strong></p>
<p style="margin-bottom: 0cm"># See /usr/share/postfix/main.cf.dist for a commented, more complete version</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm"># Debian specific:  Specifying a file name will cause the first</p>
<p style="margin-bottom: 0cm"># line of that file to be used as the name.  The Debian default</p>
<p style="margin-bottom: 0cm"># is /etc/mailname.</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm">#myorigin = /etc/mailname</p>
<p style="margin-bottom: 0cm">smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm">biff = no</p>
<p style="margin-bottom: 0cm"># appending .domain is the MUA&#8217;s job.</p>
<p style="margin-bottom: 0cm">append_dot_mydomain = no</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm"># Uncomment the next line to generate &#8220;delayed mail&#8221; warnings</p>
<p style="margin-bottom: 0cm">#delay_warning_time = 4h</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm">readme_directory = no</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm"># TLS parameters</p>
<p style="margin-bottom: 0cm">smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem</p>
<p style="margin-bottom: 0cm">smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key</p>
<p style="margin-bottom: 0cm">smtpd_use_tls=yes</p>
<p style="margin-bottom: 0cm">smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache</p>
<p style="margin-bottom: 0cm">smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm"># See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for</p>
<p style="margin-bottom: 0cm"># information on enabling SSL in the smtp client.</p>
<p style="margin-bottom: 0cm">&nbsp;</p>
<p style="margin-bottom: 0cm">myhostname = example.com</p>
<p style="margin-bottom: 0cm">alias_maps = hash:/etc/aliases</p>
<p style="margin-bottom: 0cm">alias_database = hash:/etc/aliases</p>
<p style="margin-bottom: 0cm">mydestination = $myhostname, foo.com, localhost.localdomain, localhost</p>
<p style="margin-bottom: 0cm">relayhost = foo.com</p>
<p style="margin-bottom: 0cm">relay_domains = foo.com</p>
<p style="margin-bottom: 0cm">mynetworks_style = subnet</p>
<p style="margin-bottom: 0cm">smtp_sasl_auth_enable = yes</p>
<p style="margin-bottom: 0cm">smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd</p>
<p style="margin-bottom: 0cm">smtp_sasl_security_options =</p>
<p style="margin-bottom: 0cm">mynetworks = 127.0.0.0/8</p>
<p style="margin-bottom: 0cm">mailbox_size_limit = 0</p>
<p style="margin-bottom: 0cm">recipient_delimiter = +</p>
<p style="margin-bottom: 0cm">inet_interfaces = all</p>
<p style="margin-bottom: 0cm">virtual_alias_maps = hash:/etc/postfix/virtual</p>
<p style="margin-bottom: 0cm"><strong>What domain to use in outbound mail</strong></p>
<p style="margin-bottom: 0cm">The <strong>myorigin</strong> parameter specifies the domain that appears in mail that is posted on this machine.</p>
<dl>
<dt style="margin-bottom: 0.5cm">Examples:  	</dt>
<dd> 	<strong>myorigin = $myhostname</strong> (default)  	</dd>
<dd> 	<strong>myorigin = $mydomain</strong> (probably desirable)</dd>
</dl>
<p style="margin-bottom: 0cm"><strong>What domains to receive mail for</strong></p>
<p style="margin-bottom: 0cm">The <strong>mydestination</strong> parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine. The default is to receive mail for the machine itself.</p>
<p>You can specify zero or more domain names, <em>/file/name</em> patterns and/or <em>type:name</em> lookup tables, separated by whitespace and/or commas. A <em>/file/name</em> is replaced by its contents; <em>type:name</em> requests that a table lookup is done.</p>
<p>If your machine is a mail server for its entire domain, you must list <strong>$mydomain</strong> as well.</p>
<p style="margin-bottom: 0cm">Examples:</p>
<dl>
<dt>Default setting:  	</dt>
<dd style="margin-bottom: 0.5cm"> 	<strong>mydestination = $myhostname localhost.$mydomain</strong>  	</dd>
<dt> 	Domain-wide mail server:  	</dt>
<dd style="margin-bottom: 0.5cm"> 	<strong>mydestination = $myhostname localhost.$mydomain $mydomain </strong> 	</dd>
<dt> 	Host with multiple DNS A records:  	</dt>
<dd style="margin-bottom: 0.5cm"> 	<strong>mydestination = $myhostname localhost.$mydomain www.$mydomain 	ftp.$mydomain</strong>  	</dd>
</dl>
<p style="margin-bottom: 0cm"> <strong>What clients to relay mail for </strong></p>
<p>By default, Postfix will relay mail for clients in authorized networks.</p>
<p>Authorized client networks are defined by the mynetworks parameter. The default is to authorize all clients in the IP subnetworks that the local machine is attached to.</p>
<p style="margin-bottom: 0cm"><strong>My own hostname </strong></p>
<p>The <strong>myhostname</strong> parameter describes the fully-qualified domain name of the machine running the Postfix system. <strong>$myhostname</strong> appears as the default value in many other Postfix configuration parameters.</p>
<p>By default, <strong>myhostname</strong> is set to the local machine name. If your machine name is not in fully-qualified domain name form, or if you run Postfix on a virtual interface, you will have to specify the fully-qualified domain name that the mail system should use.</p>
<dl>
<dt style="margin-bottom: 0.5cm">Examples:  	</dt>
<dd> 	<strong>myhostname = host.local.domain</strong> (local hostname is not FQDN)  	</dd>
<dd> 	<strong>myhostname = host.virtual.domain</strong> (virtual interface)  	</dd>
<dd style="margin-bottom: 0.5cm"> 	<strong>myhostname = virtual.domain</strong> (virtual interface)  	</dd>
</dl>
<p style="margin-bottom: 0cm"> <strong>My own domain name </strong></p>
<p>The <strong>mydomain</strong> parameter specifies the parent domain of <strong>$myhostname.</strong> By default it is derived from <strong>$myhostname</strong> by stripping off the first part (unless the result would be a top-level domain).</p>
<dl>
<dt style="margin-bottom: 0.5cm">Examples:  	</dt>
<dd> 	<strong>mydomain = local.domain</strong>  	</dd>
<dd style="margin-bottom: 0.5cm"> 	<strong>mydomain = virtual.domain</strong> (virtual interface)  	</dd>
</dl>
<p style="margin-bottom: 0cm"><strong>My own networks</strong></p>
<p>The <strong>mynetworks</strong> parameter lists all networks that this machine somehow trusts. This information can be used by the <a href="http://www.postfix.org/uce.html#smtpd_recipient_restrictions">anti-UCE</a> features to recognize trusted SMTP clients that are allowed to relay mail through Postfix.</p>
<p>You can specify the list of trusted networks in the <strong>main.cf</strong> file, or you can let Postfix deduce the list for you. The default is to let Postfix do the work for you.</p>
<dl>
<dt>Default:  	</dt>
<dd style="margin-bottom: 0.5cm"> 	<strong>mynetworks_style = subnet</strong>  	</dd>
<dt style="margin-bottom: 0.5cm"> 	The meaning of the styles is as follows:  	</dt>
<dl>
<dt> 		<strong>class</strong>  		</dt>
<dd style="margin-bottom: 0.5cm"> 		Trust SMTP clients in the class A/B/C networks that Postfix is 		connected to. <strong>Don&#8217;t do this with a dialup site &#8211; it would cause 		Postfix to &#8220;trust&#8221; your entire provider&#8217;s network. 		Instead, specify an explicit mynetworks list by hand, as described 		below</strong>.  		</dd>
<dt> 		<strong>subnet</strong> (default)  		</dt>
<dd style="margin-bottom: 0.5cm"> 		Trust SMTP clients in the IP subnetworks that Postfix is connected 		to.  		</dd>
<dt> 		<strong>host</strong>  		</dt>
<dd style="margin-bottom: 0.5cm"> 		Trust only the local machine.  		</dd>
</dl>
</dl>
<p> Alternatively, you can specify the <strong>mynetworks</strong> list by hand, in which case Postfix ignores the <strong>mynetworks_style</strong> setting. To specify the list of trusted networks by hand, specify network blocks in CIDR (network/mask) notation, for example:</p>
<dl>
<dd style="margin-bottom: 0.5cm"><strong>mynetworks = 168.100.189.0/28, 	127.0.0.0/8</strong>  	</dd>
</dl>
<p> You can also specify the absolute pathname of a pattern file instead of listing the patterns in the <strong>main.cf</strong> file.</p>
<p style="margin-bottom: 0cm"> <a title="inet_interfaces" name="inet_interfaces"></a><strong>My own network addresses </strong></p>
<p>The <strong>inet_interfaces</strong> parameter specifies all network interface addresses that the Postfix system should listen on; mail addressed to <em>user</em>@[<em>network address</em>] will be delivered locally, as if it is addressed to a domain listed in <strong>$mydestination. </strong></p>
<p>The default is to listen on all active interfaces. If you run mailers on virtual interfaces, you will have to specify what interfaces to listen on.</p>
<p>You even have to specify explicit machine interfaces for the non-virtual mailer that receives mail for the machine itself: the non-virtual mailer should never listen on the virtual interfaces or you would have a mailer loop.</p>
<dl>
<dt style="margin-bottom: 0.5cm">Examples:  	</dt>
<dl>
<dt> 		Default:  		</dt>
<dd style="margin-bottom: 0.5cm"> 		<strong>inet_interfaces = all</strong>  		</dd>
<dt> 		Host running virtual mailers:  		</dt>
<dd> 		<strong>inet_interfaces = virtual.host.tld</strong> (virtual domain)  		</dd>
<dd style="margin-bottom: 0.5cm"> 		<strong>inet_interfaces = $myhostname localhost.$mydomain</strong> 		(non-virtual mailer)  		</dd>
</dl>
</dl>
<p style="margin-bottom: 0cm"> <strong>What delivery method: direct or indirect </strong></p>
<p>By default, Postfix tries to deliver mail directly to the Internet. Depending on your local conditions this may not be possible or desirable. For example, your system may be turned off outside office hours, it may be behind a firewall, or it may be connected via a provider who does not allow direct mail to the Internet. In those cases you need to configure Postfix to deliver mail indirectly via a relay host.</p>
<p>Examples (specify only one of the following):</p>
<p>/etc/postfix/main.cf</p>
<p style="margin-bottom: 0cm">    <font size="3">	<a href="http://www.postfix.org/postconf.5.html#relayhost">relayhost</a> =                   			(default: direct delivery to Internet)</font></p>
<p style="margin-bottom: 0cm">    <font size="3">	<a href="http://www.postfix.org/postconf.5.html#relayhost">relayhost</a> = $<a href="http://www.postfix.org/postconf.5.html#mydomain">mydomain</a>         		(deliver via local mailhub)</font></p>
<p style="margin-bottom: 0cm">    <font size="3">	<a href="http://www.postfix.org/postconf.5.html#relayhost">relayhost</a> = [mail.$<a href="http://www.postfix.org/postconf.5.html#mydomain">mydomain</a>]  	(deliver via local mailhub)</font></p>
<p style="margin-bottom: 0cm">    <font size="3">	<a href="http://www.postfix.org/postconf.5.html#relayhost">relayhost</a> = [mail.isp.tld]    		(deliver via provider mailhub)</font></p>
<p>The form enclosed with <tt>[]</tt> eliminates DNS MX lookups. Don&#8217;t worry if you don&#8217;t know what that means.</p>
<p style="margin-bottom: 0cm"><strong>What destinations to relay mail to </strong></p>
<p>By default, Postfix will forward mail from strangers (clients outside authorized networks) to authorized remote destinations only. Authorized remote destinations are defined with the <a href="http://www.postfix.org/postconf.5.html#relay_domains">relay_domains</a> configuration parameter. The default is to authorize all domains (and subdomains) of the domains listed with the <a href="http://www.postfix.org/postconf.5.html#mydestination">mydestination</a> parameter.</p>
<p>Examples (specify only one of the following):</p>
<p style="margin-bottom: 0cm">	/etc/postfix/main.cf:</p>
<p style="margin-bottom: 0cm">    	<a href="http://www.postfix.org/postconf.5.html#relay_domains">relay_domains</a> = $<a href="http://www.postfix.org/postconf.5.html#mydestination">mydestination</a> 	(default)</p>
<p style="margin-bottom: 0cm">   	 <a href="http://www.postfix.org/postconf.5.html#relay_domains">relay_domains</a> =           			(safe: never forward mail from strangers)</p>
<p style="margin-bottom: 0cm">   	 <a href="http://www.postfix.org/postconf.5.html#relay_domains">relay_domains</a> = $<a href="http://www.postfix.org/postconf.5.html#mydomain">mydomain</a> 	(forward mail to my domain and subdomains)</p>
<p style="margin-bottom: 0cm"><strong>Virtual Alias Domain</strong></p>
<p>The place we are going to make a few changes. Let&#8217;s say I want to be able to relay mail sent to user at mydomain.org to my personnal adress chantra@foo.bar.</p>
<p>In the first place I need to define a <strong>virtual alias domain</strong>.</p>
<p>Add</p>
<p>virtual_alias_domains = mydomain.org</p>
<p>Then, we need to tell postfix where the alias database is:</p>
<p>virtual_alias_maps = hash:/etc/postfix/virtual</p>
<p><strong>Step 3. Create New File virtual</strong></p>
<p>Adding those 2 lines is sufficient to make your box treat the mail sent to debuntu.org. Now, we need to tell postfix what to do with the mails.</p>
<p>Create and Edit the file <strong>/etc/postfix/virtual</strong> and add:</p>
<p>chantra@mydomain.org  chantra@foobar.org<br />
localuser@mydomain.org myuser<br />
@mydomain.org catch-all@foobar.org</p>
<p>At the first line, we say that we want all the mail to chantra@mydomain.org to be forwarded to chantra@foobar.org.</p>
<p>On the second line we tell postfix to deliver the mails to localuser@mydomain.org to the Unix user <strong>myuser</strong>.</p>
<p>On line 3, we define a <strong>catch-all adress</strong> which will forward any mails to mail account to the mail account <em>catch-all@foobar.org</em></p>
<p><strong>Step 4. Generating  .db file</strong></p>
<p>Now we need to regenerate the <strong>aliases</strong> database as well as the <strong>virtual mail aliases</strong> database. To do so, execute the following commands:</p>
<p>root@laptop:~#newaliases<br />
root@laptop:~#postmap /etc/postfix/virtual</p>
<p><strong>Step 5. Setting fully qualified domin name (eg: example.com)</strong></p>
<p>Add the fully qualifed domin name to the file  /etc/mailname</p>
<p>$ vi /etc/mailname</p>
<p><strong>Step 6. Restart Postfix</strong></p>
<p>And restart postfix:</p>
<p>root@laptop:~#/etc/init.d/postfix restart</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fpostfix-and-virtual-hosts%2F&amp;linkname=Postfix%20Mail%20Server%20with%20catch%20all%20E-Mails"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/postfix-and-virtual-hosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
