On Wed, Jul 22, 2015 at 05:01:48PM +0300, Edgaras Luko?evi?ius wrote: > Now I have some aliases in SQL `alias` table.
Are these virtual(5) aliases or local aliases(5)? > By default when postfix > unpacks this alias and sees external recipient it will send email through > first primary IP address of the server. No routing at all. That's nonsense, the (final alias-expanded) recipient domain determines the address class: http://www.postfix.org/ADDRESS_CLASS_README.html If that address class is "default" and there is no transport table override for the domain in question, then the sender address (via sender_dependent_default_transport) can be used to select one of a set of transports that handle the outbound email. > Example: > > alias.address | alias.goto > +---------------|--------------------+ > alias1@mydomain | recipie...@gmail.com > alias2@mydomain | recipie...@gmail.com The final recipient address is in the "goto" column. This is the address used to determine the address class. Since (presumably) gmail.com is not one of your own domains, the address class will be "default", and the sender address can be used to select a suitable outbound transport (unless there's transport override for gmail.com). > I want emails received: > * by alias1@mydomain and forwarded to external destination > recipie...@gmail.com to be delivered through outbound1 This is not possible, and for good reason, the routing of mail must be based on the destination address, not the alias through which it is expanded. > * by alias2@mydomain and forwarded to external destination > recipie...@gmail.com to be delivered through outbound2 Why would you want this? The only thing that approximates this is the "owner-alias" feature of the local(8) delivery agent, in which aliases with an "owner-alias" get their sender address replaced by the "owner-alias" (or its expansion). Then the resulting mail will do default transport selection based on the new envelope sender. This requires that the aliases in question be local aliases(5). > Now If I receive email from send...@hotmail.com to alias alias1@mydomain and > forward it to recipie...@gmail.com > sender: send...@hotmail.com > recipient: alias1@mydomain > > after unpacking: > sender: send...@hotmail.com > recipient: recipie...@gmail.com > > Obviously, sender_dependent_default_transport_maps won't work here. It works exactly as documented, by selecting the transport based on the sender. -- Viktor.