Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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 Jul 27 '10 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 Jul 27 '10 at 17:20
add comment

2 Answers

up vote 4 down vote accepted

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 forward to the intended recipient, just remove it.

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

share|improve this answer
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 Jul 27 '10 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 Jul 27 '10 at 17:44
exim -bt address@example.com 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 Jul 27 '10 at 17:45
add comment

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.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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