I am trying to come up with an exim router that can handle mail addressed to any subdomain of one of my hosted domains, and deliver it to a given address on the system. (Ultimately, the received email will be piped to a script for automated processing by my application - the subdomain will represent a client's account name). For example:

test@subone.mydomain.com -> test@mydomain.com
test@subtwo.mydomain.com -> test@mydomain.com
something@subanother.mydomain.com -> something@mydomain.com

I have to be able to use wildcards in the router as the rule must handle unknown subdomains in the address - I cannot hard code or list specific subdomains like "subone", "subtwo", "subanother" in the example above.

So far I have created a file called /etc/wildcard_subdomains containing:
Code:
*.mydomain.com   mydomain.com
I have tried adding a router as below to the Advanced Exim Config editor of WHM under the "ROUTERS CONFIGURATION" section, directly under the "democheck" router:

Code:
wildcard_subdomains:
    driver = redirect
    domains = partial-lsearch;/etc/wildcard_subdomains
    data = ${lookup{$local_part}lsearch*{/etc/valiases/$domain_data}}
I have not added any extra lines to /etc/localdomains or /etc/userdomains.

When I do this, I cannot send email to an example address of test@subone.mydomain.com from my GoogleMail account - it bounces with this error:
Code:
550-<google IP> is currently
550-not permitted to relay through this server. Perhaps you have not logged
550-into the pop/imap server in the last 30 minutes or do not have SMTP
550 Authentication turned on in your email client.
If I attempt to send an email to that address from a local user account instead, it will route but to the catchall mailbox of mydomain.com. (I have a forward set for test@mydomain.com to forward mail to my main email address).

Can anyone help me achieve the desired re-routing with an appropriate Exim rule?

Many thanks for any help.

Flying Fox