Re: [exim] Issue with using alias file

Etusivu
Poista viesti
Vastaa
Lähettäjä: Mike Brudenell
Päiväys:  
Vastaanottaja: Exim Users
Aihe: Re: [exim] Issue with using alias file
Hi, anonymous person -

On 27 October 2016 at 02:34, 3YSTech Services <3ystechservices@???>
wrote:

> I still can't figure out how to redirect EXIM to lookup local alias file
> for all mail delivery,but was able to figure out why it is not working. The
> issue seems to be aliases point to domain not in local domain list ..
>


Alias section comes after dnslookup and smarthost sections


Remember that "local domains" are the ones your email server is responsible
for accepting and storing messages yourself. Aliases let you create
additional email addresses for various mailboxes.

What are these "other" domains you're wanting to "look up aliases" for? If
the domains aren't yours then it's not polite to fiddle with email
addresses that belong to other people's domains!

However there is are some use-cases: if your server is "virtual hosting"
email addresses for domains you are responsible for, mapping them to real
email addresses elsewhere. So I'm hoping that's what you're trying to do.

It sounds like you might not taken the time to read through the *Exim
Specification*, and in particular the chapter that explains the default
configuration file
<http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_default_configuration_file.html>
Exim
comes with. In there you'll read that the order in which the routers appear
in your configuration file is *important*.

Exim starts off at the router that's listed first and sees whether its
conditions are met. If they are the router is run, otherwise Exim moves on
to try the next router.

The routers in Exim's default configuration follow this general process:

1. For any recipient domains that aren't local, use the dnslookup router
to figure out where to send the message and send it off there;
2. (Only if you uncomment the "smarthost" router…) For any recipient
domains that aren't local and haven't already been dealt with use the
manualroute router to send the messages to your smarthost.
3. Having dealt with non-local domains whatever recipients are left must
be in your own local domains, so…
4. The system_aliases router checks your aliases file;
5. The userforward router checks for any forwarding instructions your
users have set up;
6. The localuser router delivers the message by writing it to your
user's mailbox.

In some circumstances the list of routers can be re-run from the first one
again… for example if you alias an address to one or more others.

If you are wanting to check an aliases file for other domains (that aren't
your own local ones but which you are still responsible for) then:

- *don't* just move the system_aliases router to before the dnslookup
and smarthost routers — doing so will make *your* aliases file apply to
every address on the Internet for the messages flowing through your server;
- instead look at adding a new, different router *before* the dnslookup
router that consults the aliases file for the whichever other domain(s)
you're wanting to do this for.

We use this technique to "virtual host" email addresses for some domains we
own, but which aren't "local" (that is, their users don't have mailboxes
for their domains on our server). Instead we use per-domain aliases files
to map each the recipient addresses in each of these domains to a real
mailbox's email address.

For example, something like this router would go before our dnslookup
router:

do_vhosting:
  driver        = redirect
  require_files = /etc/exim4/virtual-domains.d/${domain}-aliases
  qualify_preserve_domain
  allow_fail
  data          = ${expand:${lookup {$local_part} lsearch*
{/etc/exim4/virtual-domains.d/${domain}-aliases}}}


This constructs a filename based on the domain of the recipient address and
checks to see if it exists. If it doesn't, the router doesn't run and Exim
moves on to the next router in the configuration file.

But if the file does exist it's searched for the local part of the email
address and, if an entry is found, the address(es) that are its value
become the new recipients.

The lines in the file look like your usual aliases. So if the file were
"example.com-aliases" then it would be consulted only for "@???"
recipient addresses, and the entries might look like:

webmaster: jonny.appleseed@???


Tips:

- This is useful if you have a number of different domains. If you've
only got a few and want to put everything in one file you could put full
email addresses in as the keys instead of just the local parts; you'll ned
to change the lookup code as well to match.
- If some of the domains have lots of entries in the files you should
probably build a database file and do a lookup on that rather than an
lsearch through a plain text file as it'll be more efficient.

Once you've got something in place on your test system then check and
double-check it. Exim with the "-bt" option is useful for this to see check
what address Exim will deliver to:

exim -bt webmaster@???
exim -bt someoneelse@???


Make sure that only the domains you are expecting to be handled are dealt
with, and only the addresses you want aliased are.

If it isn't working as your expect, try using the "-bhc" command line
option to run Exim in testing mode with a fake SMTP session; it'll describe
every router it encounters, every condition it checks, and every action it
performs. From this you can see what it's doing and should be able to work
out where your mistake lies.

Cheers,
Mike B-)

--
Systems Administrator & Change Manager
IT Services, University of York, Heslington, York YO10 5DD, UK
Tel: +44-(0)1904-323811

Web: www.york.ac.uk/it-services
Disclaimer: www.york.ac.uk/docs/disclaimer/email.htm