There are lots of reasons to not do it that way, but if you're really interested you can start with this, published on the exim-users mailing list about three years ago.
Jeff
With perl I can read MX records provided by the exim, and return the IP address to exim.