This site is now 100% read-only, and retired.

Exim4 with multiple aliases for some internal users?

Posted by ybiC on Mon 10 Apr 2006 at 09:45

Tags: ,

I'm configuring a Debian Sarge/Exim4 host to act as an email gateway between the internet and a private LAN email server. The intent is to forward incoming email messages for some users not only to the internal email host, but also back out to their home email addresses.

The Exim FAQ Q0427 shows a technique that looks promising - mulitple aliases files. But in which Exim configuration file should the given block be placed? Fwiw, I'm using the default of "multiple config files" for Exim4.

Or is there a better approach?
cheers,
ybiC



Q0427
Question

How can I have an address looked up in two different alias files, and delivered to all the addresses that are found?

Answer
Use a router like this:
multi_aliases:
  driver = redirect
  data = ${lookup{$local_part}lsearch{/etc/aliases1}\
    {$value${lookup{$local_part}lsearch{/etc/aliases2}{,$value

\

    *

      {${lookup{$local_part}lsearch{/etc/aliases2}{$value}fail}}}\

}}}

If the first lookup succeeds, the result is its data, followed by the data from the second lookup, if any, separated by a comma. If the first lookup fails, the result is the data from the third lookup (which also looks in the second file), but if this also fails, the entire expansion is forced to fail, thereby causing the router to decline.

Another approach is to use two routers, with the first re-generating the original local part when it succeeds. This won't get processed by the same router again. For example:

multi_aliases1:
  driver = redirect
  data = ${lookup{$local_part}lsearch{/etc/aliases1}{$value,$local_part}}

multi_aliases2:
  data = ${lookup{$local_part}lsearch{/etc/aliases2}}

This scales more easily to three or more alias files.

 

 


Re: Exim4 with multiple aliases for some internal users?
Posted by Anonymous (62.178.xx.xx) on Mon 10 Apr 2006 at 10:43
If you only need multiple aliases, you can easily write in your /etc/aliases
foo: foo@internal, foo@external
This will create copies to both internal and external mailbox. There is no need for multiple alias files.

[ Parent ]

Re: Exim4 with multiple aliases for some internal users?
Posted by ybiC (68.96.xx.xx) on Tue 11 Apr 2006 at 14:42

Ah, thanks anonymous. I was looking waaay too hard.

Hmmm... any thoughts on an Exim equivelent to Sendmail's virtusertable, so I wouldn't have to have local accounts on the email gateway?

[ Parent ]

Re: Exim4 with multiple aliases for some internal users?
Posted by Anonymous (85.22.xx.xx) on Sat 15 Apr 2006 at 12:22
You don't need local accounts for alias addresses. Just put them in your alias file and you're done.

[ Parent ]

Re: Exim4 with multiple aliases for some internal users?
Posted by Anonymous (157.159.xx.xx) on Wed 24 May 2006 at 15:37
Note that the snippets are badly rendered in this article. You should check the referred FAQ for proper syntax

[ Parent ]