Home Technical Articles Exim – Basics

Exim – Basics

by SupportPRO Admin

HISTORY

* Exim was written by Philip Hazel at the University of Cambridge in 1995.
* Written using the basic philosophy of Smail
* The name was derived from Experimental Internet Mailer as the outcome of the project at start was unknown.

EXIM

* Exim is Open Source and distributed under the GNU General Public License (GPL)
* Exim is a Mail Transfer Agent (MTA)

INTERNET MAIL TRANSPORT AGENTS

* MTA Mail Transfer Agent
MTA is a program used for transporting mail from one host to another. Messages sent from one host to another use the Simple Mail Transfer Protocol (SMTP).

* MUA Mail User Agent
The program people most often use to send/receive mail are referred to as Mail UserAgents (MUAs). They exist to provide convenient mail interfaces for users. Examples are Outlook, Thunderbird, iMail, etc

The MUA simply sends the mail to the MTA which then transports the mail from host to host until its delivered to mailbox and retrieved using an MTA

MDA Mail Delivery Agent
A Mail Delivery Agent (MDA) is used by the MTA to deliver email to a particular users mailbox.

EXIM PORT

* SMTP listens on TCP port 25. Because of this, Exim must be run as a priviledged program.

* Port 465 is reserved for SMTP over SSL. However, Exim employs Transport Layer Security (TLS) in order to not need a seperate port for secure communications.

HEADERS

* RFC 2822 is standard used for the message format.
* RFC 2822 – Internet Message Format. It is an international standard that defines the format of SMTP email
* A message consists of a header and a body. The header contains a number of lines as defined by RFC 2822.
* RFC 2822 allows many variations for addresses, such as :
To: example@example.com
John Doe <example@example.com>
example@example.com (John Doe)

* Many header lines are added by the MTA. In addition to the header and the body,an envelope is transmitted immediately before the headers using SMTP commands MAIL and RCPT.
* Envelope contains sender address and at least one recipient address. Always in form of <user@domain>.
* Delivery is based completely on the envelope, not the To: or Cc: lines. Any message failures are always sent to the envelope from address, not the From: or Reply-to: address.
* Additional header lines are also added by the MUA and MTA. Before transmitting message, Date: and Message-ID: line always added by the MUA. Many other headers can also be added by MUA and MTA.
* SpamAssassin on cPanel servers add headers which are prefixed with X-Spam. Other headers can be added based on the Exim configuration.

HOW SMTP WORKS

* SMTP is a Simple command-reply protocol. Client host sends command and awaits a reply.

MUA =requests=> MTA
MTA =220 ESMTP Ready=> MUA
MUA =EHLO=> MTA
MTA =Accept=> MUA
MUA =From=> MTA
MUA =To=> MTA
MTA =Accepted=> MUA
MUA =Data=> MTA
MTA =354=> MUA
MUA =send=> MTA
QUIT

EXIM IN CPANEL

On cPanel servers, both /usr/lib/sendmail and /usr/sbin/sendmail are symlinks to the Exim binary.

Most exim processes act seperately and are short lived. The exception to this is:

1) Process to listen on SMTP port for incoming TCP/IP connections
2) Process to start up queue runner processes.

Exim configuration file is stored at /etc/exim.conf on cPanel servers. However, all modifications to the exim.conf can be made through the Advanced Exim Configuration Editor in WHM.

MESSAGE ID

Every message handled by Exim is issued a unique Message-ID.
The ID is 16 characters and seperated into 3 parts by hyphens. Each part is actually a number, encoded in base 62.
The first part is the unix time the message started to be received. The second part is the PID of the process that received it. The third part is are used to distinguish between processes received by the same process at the very same moment.

EXIM QUEUE

* The exim queue on cPanel servers is stored at /var/spool/exim/input
* On cPanel servers, we opt to split the queue into 62 subdirectories. ([a-z], [A-Z], and [0-9]). This causes all messages to be distributed to the seperate subdirectories based on the 6th character in the message ID.
* This requires Exim to do more work when scanning the queue, but vastly improves the disk writing performance.

EXIM COMMANDS

* You can manage the Exim queue from command line very easily.
* To list the contents of the queue, you would simply use the command:
exim -bp
* To only give you the number of emails in the spool you simply add a c to the end of the command:
exim -bpc
* You can examine the contents of a message in queue using the exim -Mvl command followed by the Message ID

EXIM STATS

* We use the eximstats daemon to monitor your exim queue.
* Eximstats is a perl script which parses logs and creates a mysql database with many different statistics about Exim.
* Most of this information can be accessed through WHM using the View Mail Statistics option.
* To restart eximstats you would use /scripts/restartsrv_eximstats.

TroubleShooting EXIM

* There are many troubleshooting techniques you can use on the command line for Exim.
* To test how Exim would route a message you simply use the exim -bt command, for instance:
exim -bt nick@example.com
* This will tell you which routers Exim would use to deliver a message to this address.

EXIM LOG FILES

* There are three log files available for you to monitor the activities of Exim.
– The main exim log file (exim_mainlog) records the arrival of each message as well as the delivery in a single logical line.
– The reject log file (exim_rejectlog) records information about messages and addresses that are rejected based on policy.
The exim panic log (exim_paniclog) is only used when Exim suffers a disastrous error. (most often related to syntax errors in the log files).

EXIM.CONF

* The exim configuration editor can be accessed through WHM for modifying any aspect of the exim.conf.
* This editor also allows you some simple configuration options such as:
Always set the Sender: header when the sender is changed from the actual sender. (Unchecking this will stop On behalf of data in Microsoft(R) Outlook, but may limit your ability to track abuse of the mail system.)
* Verify the existance of email senders.
* Use callouts to verify the existance of email senders.
* Discard emails for users who have exceeded their quota instead of keeping them in the queue.

MAILDIR VS MBOX

* The best advantage of Maildir over other mailbox formats is maildir does not require locks as its all seperate files.
* All mail is written to a tmp directory first, and then written to the new directory.
* Once the MUA finds mail in the new directory, it will move it to the cur directory.
* All cPanel servers now come default using Maildir instead of mbox. However, for any old systems which have not yet been converted to maildir, you can simply use the script:
/scripts/convert2maildir
* Maildir is especially beneficial for servers that pass large volumes of mail.

EXIM FACTS FOR THE SUPPORT TEAM

RELAYING
RBL
Finding A Mail From Log
SPAMD
CLAMD
Article Authored by Nobin Joseph

Author, Nobin, is a Sr.Systems Engineer with SupportPRO. Nobin specializes in Exim,Cpanel and Linux servers. SupportPRO offers 24X7 technical support services to Web hosting companies and service providers.

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment