I have exim running on a development server.

It's currently not able to deliver mail anywhere other than locally. This is fine though - I don't want to be able to accidentally spam our entire userbase. But it does make it difficult to see if the email system is working.

So, I want to capture all emails that exim tries to send (these emails are generated by a web-based CRM system on the same server), and store them in a shared mailbox (that I plan to make accessible to all developers via Dovecot/IMAP)

i.e. I want to redirect all outbound email to a local mbox.

Is this possible? I'm a complete exim beginner, and struggling with it.

  • Do you want to store locally in /var/mail (in mbox format) or do you want to pass emails on to dovecot? You could first put it in /var/mail and then pass it on to dovecot with fetchmail or something, but I don't see the why you'd want that.
    – Jasper
    Commented Jul 27, 2010 at 16:52
  • I assumed you had to put mail into an mbox before dovecot could read it. If exim can put email directly into dovecot, that would be great. As you can tell, I have very little knowledge* about this area. (*i.e. none)
    – aidan
    Commented Jul 27, 2010 at 17:20

2 Answers 2


Sure you can. You must configure a redirect router, as in:

 driver = redirect
 data = admin [at] email

N.B. The unseen means "go ahead with other routers". If you want ONLY to trap email and not to forward it to the intended recipient, just remove it.

Take a look at the exim documentation, it's full of examples like this.

  • Ok, I tried that, but no luck. I'm not even sure it exim is reading my config file correctly - is there a way I can test it from the command line? Thanks for your help!
    – aidan
    Commented Jul 27, 2010 at 17:03
  • ...I found the exim documentation, but I don't know enough to find it useful - it seems to assume quite a lot, and I haven't found a good primer
    – aidan
    Commented Jul 27, 2010 at 17:44
  • 1
    exim -bt [email protected] to test which router it will cross. You have to reload the exim daemon to get it to reread the config file (kill -HUP will work)
    – jj33
    Commented Jul 27, 2010 at 17:45
  • revistalising this topic as it's exactly what I need. I try to add this redirect into my Exim via cPanel (only way to retain it through updates etc.), and it tells me every time "option setting expected: driver = redirect". Anyone has any hint?
    – opoloko
    Commented Oct 8, 2021 at 16:05
  • @opoloko the answer is from 11 years ago ;) I bet exim syntax has changed since then. Also, cPanel usually has heavy customizations done. I suggest you ask a new question. Commented Oct 8, 2021 at 16:26

A simple solution to this is to specify a new router and a corresponding transport. First, we configure exim to listen to a different port for emails which are to be delivered to the single mailbox. This example uses port 2525 on, so make sure that your CRM is configured to send messages via SMTP on this port when running the tests. If the mail server is also being used for other purposes, you will need to add this address and port to the existing local_interfaces configuration.

local_interfaces          = <;

Next we need a router which we call development in the example below. We specify a condition that messages received via SMTP on port 2525 should be accepted by this router and passed to the transport called single_box.

This should be placed immediately after the exim configuration section labelled begin routers

begin routers

 debug_print             = "R: client_development for $local_part@$domain"
 driver                  = accept
 condition               = ${if eq {$interface_port}{2525} {1}{0}}
 transport               = single_box

Next we need to define a transport, which will take the routed messages and save them somewhere. We'll keep things simple and save these in a single mailbox. The transport configuration can be placed anywhere in the section which starts begin transports

 debug_print             = "T: single_box for $local_part@$domain"
 driver                  = appendfile
 group                   = Debian-exim
 mode                    = 0660
 mode_fail_narrower      = false
 envelope_to_add         = true
 return_path_add         = true
 directory               = /home/mailspace/mailboxes/development/Maildir/
 create_directory        = true

This example creates a Maildir-format mailbox in the corresponding directory; make sure your you change this location to something suitable for your server. Also make sure your change the group name that used by the mailserver; the example here assumes a standard Debian system. Maildir is a common format where email messages are saved as individual files. These can be easily examined using a text editor and the Maildir format is supported by dovecot and courier if you want to make the mailbox available using IMAP.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .