Most mail messages are delivered immediate, this is way most MTAs are very simple, there is no need for elaborate queuing mechanisms through which all messages pass. Exim basically tries to delivery a message as soon as it arrives, but on occations a message will fail to be delivered, in such events messages wait on Exims queue and are delivered later.
All this is performed by a single binary, which operators in different ways depending on the arguments with which it was called. Sendmail can be replaced by Exim by creating a symbolic link from /usr/lib/sendmail or /usr/sbin/sendmail to the Exim binary.
In Exim there is just one single queue which is an unordered collection of messages waiting to be delivered much like a "pool", you can use the exim binary to list the messages, Messages that are not delivered first time are picked up later by the queue runner processes that scan the entire queue and start a delivery process for each message in turn.
|Display the Message Queue
|# exim -bp
Receiving and Delivering Messages
Message reception and message delivery are two seperate operations in Exim, Receiving a message consists or writing it to local spool files ("putting on the queue") and checking that the files have been successfully written before acknowledging receipt to the sending host or local process.There is only one copy of the message however many recipients there are which is spooled to the only one single queue.
Exim does alias, forwarding and mailing list expansion for local addresses and domain lookup for remote addresses every time it handles a message. It does not retain previous alias, forwarding and mail list expansion from one delivery to the next. However there is a one_time option for mailing lists, the lists addresses are added to the original list of recipients at the first delivery attempt, and no re-expansion occurs at subsequent attempts.
Exim requires process to perform two actions
In a normal configuration a single daemon process runs which deals with the above actions, however you can also configure Exim to run from inetd which will listen on port 25 and use then cron to start the queue runner processes, but it is better just to run the Exim damon which can limit load on your system.
How is Exim Configured
Configuration information supplied by the administrator, is used at two different times, one configuration files is used when building the Exim binary and another is read when whenever the binary is run.
Exim is controlled by a single text file, often called something like /usr/exim/configure or /etc/exim.conf, you can use the Exim binary to tell you where it is
|Display Exims controlfile
|# exim -bP configure_file
Whenever Exim is started it reads it configuration which can contain many parameters, but normally only a few are configured. This file is loaded into memory where Exim will use it from, for this reason if you change the file you must get the Eximdaemon to reload it.
|Read the configuration file
|# kill -HUP <exim process id>
How Exim Delivers Messages
There are many ways an address can be processed, DNS, local part in an alias file, there are sperate blocks of code in Exim for doing different kinds of processing and each is seperately and independently configurable. The word driver is used as the general term for one of these blocks of code, when you specify that a particular driver is to be used, you need only to give one or two parameters for it, some have many options whose values can be changed to vary the drivers behaviour.
There are three different kinds of driver
|The job of routers is to process addresses and delivering messages and decide what deliveries are to take place
|Transports are componenets of Exim that actually deliver messages by writing them to files or to pipes ot over SMTP connections
|this driver handles SMTP authentication
For an example in a typical configuration a message that is addressed firstname.lastname@example.org, where exim.example is a local domain would be handled
Here is a list of the drivers
|A router that accepts any address that is passed to it, normally it is used as a "catchall" router
|A transport that writes messages to local files
|A transport that generates automatic replies to messages
|A router that looksup domains in the DNS and does MX processing
|A router that handles "IP literal" addresse such as email@example.com (not used any more)
|A transport that delivers messages to external processes using LMTP (Local Mail Transfer Protocol), which is a variation of SMTP that is designed for passing messages between local processes
|A router that routes domains using locally supplied information such as a list of domains and corresponding hosts
|A transport that passes messages to external processes via pipes
|A router that runs an external program in order to route an address
|A router that handles several different kinds of redirection, including alias files, users .forward files, and Exim or Sieve filters. It can also explicity fource failure of an address
|A transport that writes messages to other hosts over TCP/IP connections, using SMTP or LMTP
The configuration may refer to the same driver more than once, but with different options, thus allowing for multiple instances of the same driver type. Each driver instance is given an identifying name in the configuration file, for use in the logging and for reference from other drivers.
Processing an Address
When routing an address, Exim offers it to each configured router in turn, until one of them is able to deal with it, so the order of the routers are import in the configuration file. Conditions can be placed on the routers such as certains domains, restricting them to certains times of the day. A router that successfully handles an address may assign it to a transport. If a router cannot handle an address it declines it and passes it onto the next router for processing, if all routers decline the address then the delivery fails. An router can give five possible returns
|Accept the address and pass it to a transport
|Decline the address and pass it onto the next router
|the router may be able to handle the address but cannot do so at the present time (DNS may not be working)
|The roputer recognizes the address and knows that routing should fail, for example you could keep a list of ex-employees and make them fail with a special message.
|The router recognizes the address, but cannot handle it itself. It requests that the address be passed to a lter router, overrriding a flase setting of more.
Below is a simple Exim configuration file, in the file are 7 routers which all do different things, I have explained what each one does, but will go into more details at a later date and you find links to this information.
notlocal: ## Name of the router instance
There are a number of common problems that can go wrong
Exim has a retry hints database to keep track of all failed messages, this is how it knows to resend messages.
Use of Transports by Routers
Some routers only change the delivery address which means that they do not require transport, but any router that sets up the message for delivery require a transport. A transport can use a pipe or append to a file, both of which use external files to specify what alias or file to use.