<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[iRedMail — [FAQ] How to relay your mails per-domain or per-user (LDAP solution)]]></title>
		<link>http://www.iredmail.org/forum/topic334-faq-how-to-relay-your-mails-perdomain-or-peruser-ldap-solution.html</link>
		<atom:link href="http://www.iredmail.org/forum/feed-rss-topic334.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [FAQ] How to relay your mails per-domain or per-user (LDAP solution).]]></description>
		<lastBuildDate>Wed, 14 Oct 2009 08:41:52 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[[FAQ] How to relay your mails per-domain or per-user (LDAP solution)]]></title>
			<link>http://www.iredmail.org/forum/post1515.html#p1515</link>
			<description><![CDATA[<p>This tutorial is used to explain how to set per-domain or per-user mail relay with iRedMail. If they don&#039;t work for you, please post a new topic in <a href="http://www.iredmail.org/forum/forum2-iredmail-general-technical-support.html">iRedMail General Technical Support</a> forum.</p><h5>Note: iRedMail supports per-domain and per-user mail relay since 0.5.0.</h5><h5>Solution: Relay all mails for one <strong>domain</strong> to another mail server</h5><p>There are two solutions for per-domain mail relay.</p><p><strong>1) Host this mail domain as backup mx.</strong></p><p>a) To let postfix know this, you have to set &#039;domainBackupMX=yes&#039; of your mail domain in LDAP.<br />b) Comment &#039;relay_recipient_maps&#039; in postfix /etc/postfix/main.cf if you don&#039;t have mail accounts of this domain in your LDAP server.<br /></p><div class="codebox"><pre><code>#relay_recipient_maps = proxy:ldap:/etc/postfix/ldap_virtual_mailbox_maps.cf</code></pre></div><p>c) Set proper &#039;mtaTransport&#039; of your mail domain in LDAP.</p><p>If you want to relay all mails to another server which has domain name &#039;destination.com&#039;, you should set it to:<br /></p><div class="codebox"><pre><code>mtaTransport: smtp:destination:25</code></pre></div><p>Postfix will query DNS server and get ip address of MX record of &#039;destination.com&#039;.<br />If you want to use A record instead of MX record, you should set transport to:<br /></p><div class="codebox"><pre><code>mtaTransport: smtp:[destination]:25</code></pre></div><h5>Solution: Relay all mails for one <strong>user</strong> to another mail server</h5><p>Just set &#039;mtaTransport&#039; of this mail user to proper value like per-domain setting, no addition settings are required.</p><h5>Background</h5><p>iRedMail uses local command (&#039;deliver&#039; program, which provided by dovecot) to deliver all mails by default. But how does postfix know this?</p><p>Because we have below settings:</p><p>1) We have &#039;dovecot&#039; entry in postfix config, in file <strong>/etc/postfix/master.cf</strong>:<br /></p><div class="codebox"><pre><code>dovecot unix    -       n       n       -       -      pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient} -f ${sender}</code></pre></div><p>Here, &#039;dovecot&#039; is transport name, not name of some executeable program.</p><p>2) We expect Postfix use &#039;dovecot&#039; transport to deliver all mails for this domain, it&#039;s set in domain preferences which stored in LDAP, like this:<br /></p><div class="codebox"><pre><code>dn: domainName=a.cn,o=domains,dc=iredmail,dc=org
objectClass: mailDomain
domainName: a.cn
mtaTransport: dovecot             # &lt;- This one. Do you see me?
accountStatus: active
enabledService: mail
enabledService: senderbcc
enabledService: recipientbcc</code></pre></div><p>Here, we have &#039;mtaTransport=dovecot&#039;, &#039;dovecot&#039; is transport name we mentioned in 1).</p><p>3) Postfix will lookup transport name with LDAP query, it&#039;s set in postfix (/etc/postfix/main.cf):<br /></p><div class="codebox"><pre><code>transport_maps = 
    proxy:ldap:/etc/postfix/ldap_transport_maps_user.cf,
    proxy:ldap:/etc/postfix/ldap_transport_maps_domain.cf</code></pre></div><p>As you see, postfix will query per-user transport program first, if not set, it will query per-domain transport program.</p><p>4) Postfix will invoke command and arguments which set for this transport name after it get transport name with LDAP query.</p><p>As you see, command and arguments are set in postfix /etc/postfix/master.cf which we already mentioned in 1).</p><p>Not only local command are allowed in transport, you can relay mails with different transport setting. For more examples, please refer to <a href="http://www.postfix.org/transport.5.html">postfix manual - transport(5)</a>.</p>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Wed, 14 Oct 2009 08:41:52 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1515.html#p1515</guid>
		</item>
	</channel>
</rss>
