I'm trying to setup Exim on a fresh CentOS install so that it will receive mail for a collection of given addresses, and forward the mail respectively to another address. For example, receiving mail from me@example.com would be forwarded to me@gmail.com.

I figure this should be fairly straight forward... I had this working before with Sendmail, using the virtusertable - is there something similar I can do with Exim?

I'd also like to be able to send mail, but only for mail being sent from the local machine (i.e., from applications running on the server) - I don't need/want a publicly available SMTP server.

Are there any other settings I should bear in mind to make sure the mail server is secure? (i.e., prevent relaying) I'm assuming that it will be secure out of the box.



You will need to use a redirect router. Read the Exim Router specification, as it can do many things and thus can get quite complex.

Basically, you will need to set something up like this (untested)

  driver = redirect
  data = ${lookup{$sender_address}lsearch{/etc/exim4/sender_redirects}}

Then create a file in /etc/exim4/sender_redirects that contains the redirects in a line-separated colon-delimited format, like this:

me@example.com: me@gmail.com
  • 1
    Thanks Gavin, that definitely set me in the right direction. I'm using these lines: driver = redirect domains = dsearch;/etc/exim/virtual data = ${lookup{$local_part}lsearch{/etc/exim/virtual/$domain}} where 'virtual' is a directory containing file 'example.com', and lines of the form: 'me: me@gmail.com'. I also had to set my 'local_domains' to include 'example.com' (the trick with dsearch used above can be used here too). – Joe Freeman May 20 '09 at 19:37

A variation on what Joe Freeman said, without using dsearch (which gave me unknown lookup type "dsearch" error):

In the beginning of exim.conf:

domainlist local_domains = lsearch;/etc/virtual/domains
domainlist local_domains = lsearch;/etc/virtual/domains : lsearch;/etc/virtual/forwarding_domains

In the section "begin routers" add:

    driver = redirect
    domains = lsearch;/etc/virtual/forwarding_domains
    data = ${lookup{$local_part}lsearch{/etc/virtual/forwarding/$domain}}

In lsearch;/etc/virtual/forwarding_domains add your domains one per line:


And create /etc/virtual/forwarding/example.com containg:

me: me@gmail.com

Exim4 also supports old-style .forward files, plus Exim-style .forward files which begin with # Exim filter. for example, to use the latter to forward to my backup account while keeping the original in my spool for POP3 access:

# Exim filter  <== do not edit or remove this line!

unseen deliver jcomeau_ictx@example.com

far simpler, and less dangerous, than monkeying around as root in the bowels of Exim configuration, IMO. full details on this are here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.