Tuesday 19 November 2013

Creation of Global Address Book in Squirrelmail & Qmail

Qmail Server is running as mail server for my domain example.com. I have to create an address book in which all users mail ids will exist. When I login into squirrelmail web page and go to AddressBook link, by default no entry exist there. I will create Addressbook into this link for all users in domain example.com.  

The “vpasswd” file contains user information for all mail users. I will fetch data from”vpasswd” file and will create address book data using script “Address_Book” below.

[root@qmail ~]# cat /home/vpopmail/domains/example.com/vpasswd

vts:$1$iwli/pnP$6eAKRCs1yf3RdiiRKdGSJ1:1:0:V T Subramanian:/home/vpopmail/domains/example.com/0/vts:524288000S:2yff5cf9lZ
wzo:$1$/Y0lHFfy$a01lFirzDbARvkbASejfY/:1:0:Mumbai RO:/home/vpopmail/domains/example.com/wzo:524288000S:#WIDwxa9Vc
yksingh:$1$8x5rS9zL$i1K8J/ztVK0M52rMxVvpi0:1:0:Y K Singh:/home/vpopmail/domains/example.com/0/yksingh:524288000S:YPdadkN*R
ysaxena:$1$6nEpFJE0$aLB4dQutFy2siPxJX/ZzG1:1:0:Yogesh Saxena:/home/vpopmail/domains/example.com/ysaxena:524288000S:uhd0rjswq.


[root@qmail ~]# vi /scripts/Address_Book

#!/bin/bash

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

rm -rf default_abook

for i in `cat /home/vpopmail/domains/example.com/vpasswd`
 do
   echo $i > users
   mailid=$(awk -F":" '{print $1}' users)
   nameid=$(awk -F":" '{print $5}' users)

   echo "$mailid|$nameid||$mailid@example.com|" >> default_abook
   cp -f default_abook  /opt/webmail/squirrelmail/data/default_abook
 done

[root@qmail ~]# chmod 755 /scripts/Address_Book

[root@qmail ~]# crontab  -e

00 02 * * *  /scripts/Address_Book

We will set the name of global address book in squirrelmail configuration.


[root@qmail ~]# cd /opt/webmail/squirrelmail
[root@qmail squirrelmail]# ./configure
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color on
S   Save data
Q   Quit

Command >> 6

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Address Books
1.  Change LDAP Servers
2.  Use Javascript Address Book Search          : false
3.  Global file address book                    : default_abook
4.  Allow writing into global file address book : false

R   Return to Main Menu
C   Turn color on
S   Save data
Q   Quit

Command >>3
Global file address book: default_abook
And Save and Exit.

The Global Book will be displayed into Squirrelmail webmail like below screen.



No comments:

Post a Comment