Friday, May 31, 2013

Postfix, Dovecot and Active directory Integration


For Linux AD integration pls refer my earlier post (http://isvivek.blogspot.com/2013/05/redhat-linux-active-directory.html) & after AD integration proceed with this post for postfix mail server with AD authentication.

Postfix configuration

Change the below mentioned parameters, these are just basic parameters to run a postfix mail server, we can customize or enable more options as per the requirements

Step 1 :

[root@mail ~]# vim /etc/postfix/main.cf

myhostname = mail.isvivek.com  ## Enter your hostname here

mydomain = isvivek.com ## Enter your domain name here

myorigin = $mydomain ## Just uncomment this line

inet_interfaces = all  ## Uncomment and change it to all

mydestination = $myhostname, localhost.$mydomain, $mydomain  ##  Just uncomment this line

mynetworks = 192.168.248.0/24, 127.0.0.0/8 ## Uncomment and add the network which you want to allow

home_mailbox = Maildir/ ## Just uncomment this line

Save the /etc/postfix/main.cf after making the config changes.

Step 2 : Start the postfix service

Start postfix service

[root@mail ~]# /etc/init.d/postfix start
Starting postfix:                                          [  OK  ]
[root@mail ~]#

Step 3 : Test mail flow 

[root@mail ~]# telnet mail 25
Trying 192.168.248.128...
Connected to mail.
Escape character is '^]'.
220 mail.isvivek.com ESMTP Postfix
ehlo mail
250-mail.isvivek.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:isvivek@isvivek.com
250 2.1.0 Ok
rcpt to:user1@isvivek.com
250 2.1.5 Ok
data
354 End data with .
Hi

this is test mail
.
250 2.0.0 Ok: queued as CDDA142EDE
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@mail ~]#



[root@mail ~]# cd /home/ISVIVEK/user1/Maildir/new
[root@mail new]# ll
total 4
-rw------- 1 user1 domain users 456 May 31 14:25 1369990556.Vfd00I2558cM259259.mail.isvivek.com
[root@mail new]# cat 1369990556.Vfd00I2558cM259259.mail.isvivek.com
Return-Path:
X-Original-To: user1@isvivek.com
Delivered-To: user1@isvivek.com
Received: from mail (mail.isvivek.com [192.168.248.128])
        by mail.isvivek.com (Postfix) with ESMTP id CDDA142EDE
        for ; Fri, 31 May 2013 14:25:15 +0530 (IST)
Message-Id: <20130531085539 .cdda142ede="" mail.isvivek.com="">
Date: Fri, 31 May 2013 14:25:15 +0530 (IST)
From: isvivek@isvivek.com
To: undisclosed-recipients:;

Hi

this is test mail
[root@mail new]#



Dovecot configuration

Step 1: Conofigure Dovecot

[root@mail ~]# vim /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp  ## Uncomment this line
mail_location = maildir:~/Maildir  ## Add this line


Step 2 :  Start dovecot service

[root@mail ~]# /etc/init.d/dovecot start
Starting Dovecot Imap:                                     [  OK  ]
[root@mail ~]#

Step 3 : Check mail through imap/pop3

[root@mail ~]# telnet mail pop3
Trying 192.168.248.128...
Connected to mail.
Escape character is '^]'.
+OK Dovecot ready.
user user1
+OK
pass Welcome@123
+OK Logged in.
list
+OK 1 messages:
1 470
.
retr 1
+OK 470 octets
Return-Path:
X-Original-To: user1@isvivek.com
Delivered-To: user1@isvivek.com
Received: from mail (mail.isvivek.com [192.168.248.128])
        by mail.isvivek.com (Postfix) with ESMTP id CDDA142EDE
        for ; Fri, 31 May 2013 14:25:15 +0530 (IST)
Message-Id: <20130531085539 .cdda142ede="" mail.isvivek.com="">
Date: Fri, 31 May 2013 14:25:15 +0530 (IST)
From: isvivek@isvivek.com
To: undisclosed-recipients:;

Hi

this is test mail
.
quit
+OK Logging out.
Connection closed by foreign host.
[root@mail ~]#

Squirrelmail installation and configuration 

Download latest version of Squirrelmail from http://squirrelmail.org/download.php and copy the source file to linux box

Squirrelmail Configuration

Extract it to /usr/share

[root@mail share]# pwd
/usr/share
[root@mail share]# tar -xzvf /tmp/squirrelmail-webmail-1.4.22.tar.gz
[root@mail share]# mv  squirrelmail-webmail-1.4.22/  squirrelmail/
[root@mail share]# cd squirrelmail/
[root@mail squirrelmail]# ./configure

Select 1 & edit Organization Preferences
After entering all the details, enter R to return to main menu
Now select 2 & edit Server settings
After entering all the details, enter R to return to main menu

Rest of the options are optional & you can customize the look by editing Themes options in this menu. 

Save & quit from squirrelmail config menu

Apache Configuration

Step 1:  Add the below lines in /etc/httpd/conf/httpd.conf file

[root@mail ~]# vim /etc/httpd/conf/httpd.conf

Alias /webmail /usr/share/squirrelmail
    Options Indexes FollowSymLinks
    RewriteEngine On
    AllowOverride All
    DirectoryIndex index.php
    Order allow,deny
    Allow from all

Step 2 : Apache service restart

[root@mail ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@mail ~]#


Mail ID creation

As we are using AD for authentication, users are created in AD & we just need login atleast once in Linux box with AD ID so that their profile gets created in Linux box and their mailbox will get created during mail login from webmail automatically.

We are using a simple shell scripts for single user ID & for multiple users,



Once user access user profile is created in Linux box, try to login through browser from client.



Now we have configured postfix, dovecot & squirrelmail with AD authentication. All the best... 

3 comments:

  1. Problems with dovecot are not easy to fix. See here for mark email threads

    ReplyDelete
  2. i want all user in my domain should able to login my mail web server page.How to do? pls help me

    ReplyDelete
  3. I cant able to login with AD user in Web page

    ReplyDelete