Exim mail Server

Exim Mail Server
**************************************************************

Exim is a open source Mailer Transfer Agent. Written in C language. Exim is designed to handle a general mix of mails. It does not not provide independent queues for specific domains or hosts.

MTAs receive e-mail messages and recipient addresses from local users, remote hosts and deliver the messages to their destinations.A Mail Transfer Agent is necessary for sending email from a system. It uses Mail User Agent (MAU, eg:-> Mozila, Kmail,Mutt(console based MUA)) to read and write emails. MUA is basicaly used for reading and composing mails and when user want to send them MUA handed off to MTA.

Exim Uses ACL mechanism for better throughput. Access Control List takes care of everything regarding to sending data and accepting data locally or remotely. ACL will be in affect till the rejecting or accepting a message after that user can also define filters.

User defined filters will be stored in .forward file in the home directory. Exim will have a unique message-ID. Exim assign a identification number to message. Which is 16 character long divided into three part and seperated by hyphens (-) e.g. 1Lph8l-000589-Gd is a sample id for message.

1Lph8l – 000589 – Gd
Time of generation PID depend on Localhost_number

Exim handles mail in 3 phases. They are Acceptance, Routing and Delivery.

Acceptance:-> Acceptance is handled by Access Control List (ACL’s). This deals with your specific need from
****************
where you want to accept the mail and where do you want to send your mails. It will take care of any other seeting which you want to create for mail delivery before delevering or accepting the mails.

Routing:-> Routering is handled by routers. Router determines that where to send mail to remote host or local
************
host system.

Delivery:-> Delivery is controled by routers. Routers take care of delivery mechanism. Routesrs decide
************
where to send mail to the another mail server, or write to a mailbox, etc.

Now Lets start with Exim testing.
**********************************

1)-> First check with a local user.
root@ [~]# exim -bt root
root@.example.com
router = localuser, transport = local_delivery

Note:-> -bt option runs Exim in address testing mode, in which each argument is taken as an address to be tested for deliverability.

Now try with none existing user
root@ [~]# exim -bt missinguser
missinguser@.example.com is undeliverable: Unrouteable address

2)-> Now look into your /etc/aliases file and test for address
root@ [~]# exim -bt nobody
root@.example.com
nobody is a alias. If you want to receive all mails of root to your directory then add the following line.

root: your_username

3)-> Now lets move to the sending a mail from console.

exim -v -odf pratap
hello testing.
.
LOG: MAIN
pratap R=localuser T=local_delivery
LOG: MAIN
Completed

Note:->This option requests (synchronous) delivery when Exim has accepted a locally-generated message.
1Lr7jV-0004Ex-D4 This is message identification number.

-v This option causes Exim to write information to the standard error stream, describing what it is doing.

3)-> Now check the log file to confirm that mail has been delivered or not.

root@ [~]# grep 1Lr7jV-0004Ex-D4 /var/log/exim_mainlog
2009-04-07 15:06:49 1Lr7jV-0004Ex-D4 pratap R=localuser T=local_delivery
2009-04-07 15:06:49 1Lr7jV-0004Ex-D4 Completed

From here we can see that deliver has been completed. And /var/log/exim_mainlog is the log file for the exim.

4)-> Now check where is that message in the directory of user.
root@ [~]# grep 1Lr7jV-0004Ex-D4 /home/pratap/* -R
/home/pratap/mail/new/1239097009.H877637P16329..example.com,S=481: id 1Lr7jV-0004Ex-D4
/home/pratap/mail/new/1239097009.H877637P16329..example.com,S=481:Message-Id:

The mail we have send to user is in his /mail/new/ directory.

5)-> It’s time to read that mail to confirm, its the mail which we have sent to user.

root@ [~]# cat /home/pratap/mail/new/1239097009.H877637P16329..example.com\,S\=481
Return-path:
Envelope-to: pratap@.example.com
Delivery-date: Tue, 07 Apr 2009 15:06:49 +0530
Received: from root by .example.com with local (Exim 4.69)
(envelope-from <root@.example.com&g😉
id 1Lr7jV-0004Ex-D4
for pratap@.example.com; Tue, 07 Apr 2009 15:06:49 +0530
Message-Id:
From: root
Date: Tue, 07 Apr 2009 15:06:49 +0530

hello testing.

Yes!! this was the mail.

6)->Lets have a look in log file associated with Exim and cPanel Exim related log file.

/var/log/exim_mainlog or /var/log/exim/mainlog
It recives an entry everytime a message is received or deliverd.

/var/log/exim_rejectlog
It receives an entry everytime when a message rejected by ACL entries.

/var/log/exim_paniclog
Logs any entries when exim does’nt know how to handle.

/var/log/maillog & /var/log/messages
This one is a general log file for POP/IMAP/SpanAssasin. This includes all general logging information (login attempts, transactions, spam scoring), along with fatal errors.

7)->Start exim other wise you will not be able to receive mails and send mails. To confirm that exim daemon is running do this

telnet server.com / localhost / 69.50.217.18 25

to start|stop|restart exim
/etc/init.d/exim [stop|start|restart]

8)-> Queue management tests

a)-> To check a queue run the following command

exim -bp

It will show the message in the queue

b)-> If there is no messege then You can create a queue running this command , This command just put the message in the queue without its being delivered.

exim -odq address1 address2 …
Test message.
.

c)-> If you want to do manual queue run, with minimal verification output:

exim -v -q

Remove a message from the queue:

root@localhost# exim -Mrm [ … ]

Freeze a message:

root@localhost# exim -Mf [ … ]

Note )->> Without -v you won’t see any output at all on the terminal, but there will be entries in the log.

d)->Print a count of the messages in the queue:

exim -bpc

-bpc

This option counts the number of messages on the queue, and writes the total to the standard output.

e)->Test how exim will route a given address:
exim -bt alias@localdomain.com

f)->Remove all frozen messages:

root@localhost# exiqgrep -z -i | xargs exim -Mrm

freeze all queued mail from a given sender:

root@localhost# exiqgrep -i -f luser@example.tld | xargs exim -Mf

View a message’s body:

root@localhost# exim -Mvb

View a message’s logs:

root@localhost# exim -Mvl

Add a recipient to a message:

root@localhost# exim -Mar

[
… ]

Edit the sender of a message:

root@localhost# exim -Mes

Checking Relay Control
*********************************************************************
Relaying from another host

hostlist relay_from_hosts = 127.0.0.1

to

hostlist relay_from_hosts = 127.0.0.1 : xx.xx.xx.xx/mm

where xx.xx.xx.xx/mm is the classroom network. (Don’t forget to HUP the daemon.) Then try the telnet test from section 2 again. This time it should accept the request to relay. Ask one of the other students to try relaying through your host — it should work. If you can, telnet from a host outside the classroom network, and confirm that relaying is still blocked.
Allowing relaying to specific domains
The default configuration contains the line

domainlist relay_to_domains =

This defines domains to which your host will relay, wherever the message comes from. As you can see, the default list is empty, so no domains match.

—> Add some domains to this line. For example, add the domain of your home email. In my case, this would be:

domainlist relay_to_domains = pobox.com

Now we need to test that Exim will indeed relay to those domains (but not to others) from a host that does not match relay_from_hosts. Exim has a testing facility that lets you simulate an SMTP call from a remote host. Run it like this:

$ exim -bh 192.168.1.1

You will see some debugging output, and then an SMTP greeting line. Now type SMTP commands, waiting for a response between each one:

ehlo testhost
mail from:
rcpt to:
rcpt to:

You will see the tests that Exim is making as it runs the ACL after each RCPT command. Check that it allows relaying to the right domains, and not to any others. End the SMTP session with QUIT.

Some Other Useful Command
******************************************************************************

>> Search the queue for messages from a specific sender.
root@localhost# exiqgrep -f [luser]@domain

>> Search the queue for messages for a specific recipient/domain.
root@localhost# exiqgrep -r [luser]@domain

>> Print messages older than the specified number of seconds. Eg: messages older than 1 hour.
root@localhost# exiqgrep -o 3600 […]

>> Print messages younger than the specified number of seconds. Eg: messages less than an hour old.
root@localhost# exiqgrep -y 3600 […]

>> Match the size of a message with a regex. Eg: Messages between 500-599 bytes.
root@localhost# exiqgrep -s ‘^5..$’ […]

>> Match only frozen messages.
root@localhost# exiqgrep -z

>> Match only frozen messages.
root@localhost# exiqgrep -x

>> Print just the message-id of the entire queue.
root@localhost# exiqgrep -i

>> Thaw a message.
root@localhost# exim -Mt [ … ]

>> Deliver a message, whether it’s frozen or not, whether the retry time has been reached or not.
root@localhost# exim -M [ … ]

>> Deliver a message, but only if the retry time has been reached.
root@localhost# exim -Mc [ … ]

>> Force a message to fail and bounce as “cancelled by administrator”.
root@localhost# exim -Mg [ … ]

>> Remove all frozen messages.
root@localhost# exiqgrep -z -i | xargs exim -Mrm

>> Remove all messages older than five days (86400 * 2 = 172800 seconds).
root@localhost# exiqgrep -o 172800 -i | xargs exim -Mrm

>> Freeze all queued mail from a given sender.
root@localhost# exiqgrep -i -f user@example.com | xargs exim -Mf

>> View a message’s headers.
root@localhost# exim -Mvh

>> View a message’s body.
root@localhost# exim -Mvb

>> View a message’s logs.
root@localhost# exim -Mvl

>> Add a recipient to a message.
root@localhost# exim -Mar

[
… ]

>> Edit the sender of a message.
root@localhost# exim -Mes

Gửi phản hồi

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Log Out / Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Log Out / Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Log Out / Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Log Out / Thay đổi )

Connecting to %s

%d bloggers like this: