Pages

Wednesday, May 11, 2011

Dovecot POP3/IMAP Server Setup Howto for RHEL/CentOS 5

 Dovecot:       Dovecot is an open source IMAP and POP3 email server for Linux/UNIX-like systems, written with security primarily in mind. Dovecot is an excellent choice for both small and large installations. It's fast, simple to set up, requires no special administration and it uses very little memory.

 

Install Dovecot:  Installing and setting up Dovecot in Red Hat Enterprise Linux 5 or CentOS 5 is easy. All we have to do is to enable the services we would like to provide and we are good to go.

 Make the use of yum or download dovecot and install it.

Here I have  installed it using yum. i.e use 

#yum install dovecot

Configure Postfix:

Go to the main configuration file dovecot.conf in /etc/dovecot.conf .We need to change a few key items. 

Find the following keys and change its values as follows
protocols = pop3 pop3s imap imaps
mail_location = maildir:~/Maildir/
pop3_uidl_format = %08Xu%08Xv
imap_client_workarounds = delay-newmail outlook-idle netscape-eoh
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh 
 
For 64-bit users: Add the line login_process_size = 64 
in the file /etc/dovecot.conf. 

Lines starting with # are comments. The last two line enables workarounds for various client bugs. Save the file after completing your changes.

Test Dovecot : Sample dovecot session. Replace ks and password with any valid user name and password.

 [root@fedora ~]# telnet localhost pop3
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user ks
+OK
pass ********
+OK Logged in.
list
+OK 1 messages:
1 472
.
retr 1
+OK 472 octets
Return-Path:
X-Original-To: ks
Delivered-To: ks@fedora.localdomain
Received: from list (localhost [IPv6:::1])
        by fedora.localdomain (Postfix) with ESMTP id 76BB020509
        for ; Wed, 11 May 2011 15:39:37 +0530 (IST)
Message-Id: <20110511100949.76BB020509@fedora.localdomain>
Date: Wed, 11 May 2011 15:39:37 +0530 (IST)
From: fedora@fedora.localdomain
To: undisclosed-recipients:;

Hi This is the Mail from User *** fedora ** to ks
.
list
+OK 1 messages:
1 472
.
quit
+OK Logging out.
Connection closed by foreign host.
[root@fedora ~]#

NoteIf you encounter any problems, check the log file at /var/log/maillog.

Feel free to comment

!Enjoy
Kuldeep Sharma


 

 

 

 

Postfix MTA Configuration

Firstly Lets Introduce with Term POSTFIX:

Postfix:  In computing, Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail. It is intended as a fast, easier-to-administer, and secure alternative to the widely-used Sendmail MTA.

Install Postfix:

Make the use of yum or download postfix and install it.

Here I have  installed it using yum. i.e use 

#yum install postfix

 

Configure Postfix:

Go to the main configuration file main.cf in /etc/postfix/ directoy We need to make it listen to network request, accept mails bound to our domain and use maildir which is a better mailbox format than mbox the default. 

Find the following keys and change its values as follows.

inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/

 In main.cf, lines starting with # are comments. Save the file after completing your changes.Make sure that all mail_spool_directory lines are commented out. Otherwise, it will override the setting in the home_mailbox line above.

Now Restart the postfix service.

Sample postfix session. Replace fedora with any valid user account. The dot after the line test is a command that should be typed in.

[root@fedora ~]# telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 fedora.localdomain ESMTP Postfix
ehlo list
250-fedora.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:fedora
250 2.1.0 Ok
rcpt to:ks
250 2.1.5 Ok
data
354 End data with .
Hi This is the Mail from User *** fedora ** to ks
.
250 2.0.0 Ok: queued as 76BB020509
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@fedora ~]#
 

To check if the mail indeed exists

[root@fedora ~]# cd /home/ks/Maildir/new/
[root@fedora new]# ls
1305108617.Vfd00I2050eM84839.fedora
[root@fedora new]# vi 1305108617.Vfd00I2050eM84839.fedora
[root@fedora new]# cat 1305108617.Vfd00I2050eM84839.fedora
Return-Path:
X-Original-To: ks
Delivered-To: ks@fedora.localdomain
Received: from list (localhost [IPv6:::1])
        by fedora.localdomain (Postfix) with ESMTP id 76BB020509
        for ; Wed, 11 May 2011 15:39:37 +0530 (IST)
Message-Id: <20110511100949.76BB020509@fedora.localdomain>
Date: Wed, 11 May 2011 15:39:37 +0530 (IST)
From: fedora@fedora.localdomain
To: undisclosed-recipients:;

Hi This is the Mail from User *** fedora ** to ks
[root@fedora new]#

NoteIf you encounter any problems, check the log file at /var/log/maillog.


!Enjoy
Kuldeep Sharma