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.
Sure you can. You must configure a
redirect
router, as in: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.
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
on127.0.0.1
, 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 existinglocal_interfaces
configuration.Next we need a router which we call
development
in the example below. We specify a condition that messages received via SMTP on port2525
should be accepted by this router and passed to the transport calledsingle_box.
This should be placed immediately after the exim configuration section labelled
begin routers
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
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.