Migrating from Exchange Server to qmail

SkillSoft Press ?2004

This book provides a broad coverage of all the strategic and technical intricacies of migrating an existing Exchange server setup to run on GNU/Linux operating system, using qmail.

Table of Contents
| Introduction
| Copyright
| Chapter 1 | - | Introducing the Architecture of Messaging Systems
| Chapter 2 | - | Overview of Exchange Server
| Chapter 3 | - | Overview of qmail
| Chapter 4 | - | Installing and Running qmail
| Chapter 5 | - | Migrating Existing Mails From Exchange Server
| Chapter 6 | - | Setting up Directory Services
| Chapter 7 | - | Setting up Authentication and Authorization
| Chapter 8 | - | Migrating Calendar Services
| Chapter 9 | - | Configuring qmail
| Chapter 10 | - | Spam Filtering with qmail
| Appendix A | - | Frequently Asked Questions
| Appendix B | - | Troubleshooting qmail
| Appendix C | - | Troubleshooting Mailbox Conversion to qmail
| Appendix D | - | qmail End User License Agreement
| Index
| List of Figures
| List of Tables
| List of Listings

Introduction

About the Book

qmail is a robust Internet MTA for Unix and Unix-like operating systems. With an ever-increasing popularity of GNU/Linux as a server operating system, numerous organizations are migrating existing server setups from Microsoft-based platforms to GNU/Linux and BSD platforms.

This book provides a broad coverage of all the strategic and technical intricacies of migrating an existing Exchange server setup to run on GNU/Linux operating system, using qmail. It also discuses the aspects of migration with an emphasis on business considerations such as commercial and non-commercial support for qmail and the relative total cost of ownership. The book explains the tools for converting the mail formats from Microsoft's .dbx and .pst format to Unix's mbox and maildir formats. You also learn about the authentication schemes, and how to set up Mail User Agents (MUAs) for GNU/Linux.

This book is targeted at the audience with intermediate-advanced system administration skills on Microsoft-based platforms, and with hands on experience with using basic GNU utilities, such as tar, patch, binutils, gcc, on GNU/Linux.

About the Author

Amrita Dubey

Amrita Dubey holds a degree in Electronics and Communication engineering from BMAS Engg. College, Agra. She has undergone a training in CNCs, PLCs, and circuit designing on PCBs from "Ordanance Facory Kanpur". As a Technical Writer, Amrita has co-authored books on Digital Electronics, Integrating Java with Oracle9i, PIC microcontrollers, Robotics, and Integraing PHP and XML. She also has the knowledge of Software Quality Testing, RDBMS, SQL Server, and Database Design Studio Professional 2.21.1 software.

Monika Mahendru

Monika Mahendru holds Masters degree in Computer Applications (MCA) from IGNOU, New Delhi, India. In her 3 years of work experience, Monika has taught various programming languages, such as C, C++, and Java as well various other concepts such as Data Communication and Networking, Software Engineering, Data structures in C ,C++ , and System Analysis and Designing. She has also two months experience of co-authoring books and ReferencePoints on SQL-Server 2000 and Database Designing.

Poonam Sharma

Poonam Sharma holds a B.Com degree and DNIIT diploma. She has worked on the project of "Online Banking using VB and SQL". She has also worked on the project of "Chat Application in Java". She is proficient in Java,C++,VB,ASP,Servlets,JSP,HTML,UNIX,Linux and SQL Server 2000. She is pursuing a Master's Degree in Computer Applications. She has a two years experience in NIIT as a faculty. In her one year of experience in Technical Writing, Poonam has co-authored books on Working with Korn Shell, Administering Red Hat Linux 9, Basic Programming in C++, CS105_Unix Operating System, and Integrating PHP and XML.

Vikrant Baluni

Vikrant Baluni holds a degree in Computer Science and Engineering from Lingayas Institute of Management and Technology, Faridabad. He has undergone induatrial training at Action Construction Equipments (P) Ltd, Faridabad and Micro Engineering Corporation, Faridabad. He is proficient in Electronics and 8085 microprocessor programming. As a Technical Writer, Vikrant has co-authored books on Windows Server 2003, OpenOffice.org 1.1, jwma, NetRexx, ASP.NET, and XBRL.

Credits

I would like to thank Reena Roy and Radhika Chauhan for helping me complete the book on time. I also thank the editors and the quality assurance team for their timely help.

Copyright

Migrating from Exchange Server to qmail

Copyright © 2003 by SkillSoft Corporation

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of SkillSoft.

Trademarked names may appear in this publication. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Published by SkillSoft Corporation

20 Industrial Park Drive

Nashua, NH 03062

(603) 324-3000

information@skillsoft.com

The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author nor SkillSoft shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.

Chapter 1: Introducing the Architecture of Messaging Systems

Messaging is a method to transfer messages between two Internet users. A messaging system contains various components, such as Mail User Agent (MUA), Mail Transfer Agent (MTA), and Mail Delivery Agent (MDA) to send and receive e-mail messages over the Internet. Using e-mail protocols, a messaging system helps to send different types of data, such a graphics file and a text file in a single e-mail message.

This chapter explains the architecture of an e-mail system. It describes the role of various e-mail protocols and the migration methodology that you adopt to migrate from Exchange Server to qmail.

Exploring a Messaging System

The messaging system contains four components, which are:

MUA: Helps an end user to read and compose the e-mail messages.

MTA: Accepts the e-mail messages from a MUA, identifies the address of the recipient, and sends the e-mail message for delivery.

MDA: Accepts the e-mail messages from an MTA and places these e-mail messages in a local message store, which can either be the mailbox of an end user or a database. The message store is either the /var/spool/mail or /var/mail directory.

Access Agent: Connects MUA to the local message store through the e-mail protocols. It is not necessary that an e-mail system must contain access agents.

Describing the Role of MTAs and MUAs

MUA helps an end user to read the incoming e-mail messages in the mailbox of the end user. MUA transfers the outgoing e-mail messages to an MTA, such as qmail, sendmail, and postfix. For example, pine and mutt are the MUAs that help an end user to send and receive e-mail messages. An MUA is also referred to as a mail client.

MTA accepts an e-mail message either from an MUA or another MTA. Based on the message header, which specifies the name and address of the message sender and recipient, MTA decides the mail delivery method it must use. MTA transfers the e-mail message to an MDA, such as procmail for mail delivery.

You need to know the structure of an e-mail address, to understand how the e-mail message is transferred using MTA and MUA. An e-mail address contains two parts, local part and domain part, separated by the at the rate (@) symbol. The part of the address that precedes @ is called the local part and the part after @ is called the domain part. The local part specifies the username of the message recipient. The domain part identifies an Internet host, which receives the e-mail message. To transfer an e-mail message from an end user on a host to another end user on a remote host:

The end user who wants to send an e-mail message composes the message and starts the MUA program on local host.

The MUA automatically includes the required headers in the e-mail message based on the information provided by the end user while composing the e-mail message. It then sends the e-mail message to the MTA using Simple Mail Transfer Protocol (SMTP).

The MTA identifies the destination mail server and delivers the e-mail message using SMTP.

Note 

A mail server is a computer that stores incoming e-mail messages and sends them to an end user. It also stores the outgoing e-mail messages and transfers them to the destination address through the Internet.

The destination mail server examines the e-mail message to identify the local part of the destination address.

The remote end user runs the MUA program and retrieves the e-mail message to the local computer.

Suppose an e-mail message is sent from the domain, ronald@hosta.org to another domain, john@hostb.org, then the various parts of the e-mail system interact with each other, as shown in Figure 1-1:

Click To expand: This figure shows the various parts of the e-mail system that interact with each other to transfer an e-mail message from hosta to hostb.
Figure 1-1: Parts of the E-mail System

To transfer an e-mail message from the ronald@hosta.org domain to john@hostb.org:

The MUA on hosta transfers the e-mail message to the MTA located on the same host.

The MTA on hosta identifies the recipient address, john@hostb.org, located on another host. If an end user on one host needs to deliver an e-mail message to an end user on another host, the e-mail system uses the SMTP connection. The MTA transfers the e-mail message to a MDA using SMTP.

The MDA connects to the MTA on hostb and transfers the e-mail message to the MDA.

The MTA on hostb identifies that the message is addressed to an end user on local host. It then delivers the e-mail message to the local MDA.

The local MDA saves the e-mail message in the mailbox of the end user, John.

The end user, John, uses an MUA to read the e-mail message saved in the mailbox.

Alternatively, when an end user on a host transfers an e-mail message to another end user on the local host, the e-mail message is delivered to a local MDA. MDA transfers the e-mail message to the mailbox of the end user. The end user can access the mailbox using MUA through Post Office Protocol 3 (POP3) or Internet Message Access Protocol (IMAP).

An MTA sends back an error report to the e-mail message sender, if it cannot deliver the message to the recipient. MTA may not deliver certain e-mail messages due to the problem in network connectivity. MTA stores these e-mail messages in its local disk and retries periodically to deliver the e-mail messages.

Introducing Directory Services

Directory services provide information about network objects, such as files, end users, and e-mail addresses. You can use information stored in directory service for authentication and authorization of users to enable secure access to Internet services. For example, Domain Name System (DNS) is a directory service that stores host names and corresponding Internet Protocol (IP) addresses. This information helps a user to locate computers on a network using host names.

Note 

To learn more about directory services, refer to Chapter 6.

Introducing Calendar Services

Mailing systems provide calendar services to retrieve information about events and to-do types of calendaring and scheduling entities. An event is a calendaring and scheduling entity that represents a scheduled amount of time on a calendar. For example, an event can be a one-hour meeting of the employees of a department scheduled on the weekend. A to-do is a calendaring and scheduling entity that represents an action item. For example, a to-do can be the amount of work assigned to an individual. Applications, such as Personal Information Manager (PIM) and group schedulers manage information about the events and to-do items.

You can store all the scheduling events on a day-planner or a calendar. Calendar services can be used to transfer personal calendaring information between e-mail systems or Web browsers. When the calendar information is available on your computer, you can share the information with other calendar applications by using the clipboard and drag-and-drop functions. For example, calendar services enable you to schedule a meeting with a group of individuals who use different scheduling applications or different operating systems.

Note 

The icalendar standards define an exchange format for calendar entries.

You can move appointments and to-do tasks from an e-mail message attachment into your mailbox and use this information to plan your own schedule. Consider an e-mail message with a calendar attachment that is broadcasted to all the individuals who must attend a meeting. Each of the invitees receives the e-mail message, selects the calendar attachment, and moves the attachment to their scheduling application. As a result, all the information related to the meeting, such as date, time, and location are automatically added to the calendar of each invitee.

Note 

To learn more about calendar services, refer to Chapter 8.

Introducing the E-mail Protocols

An e-mail protocol defines a standard method used at each end of a communication channel to transmit the e-mail messages. In an e-mail system, you need to use a mail client to access a mail server. The mail client and mail server can exchange information using various e-mail protocols, which are:

IMAP: Helps to retrieve e-mail message from mail server.

Multipurpose Internet Mail Extension (MIME): Moves multimedia files through existing e-mail gateways, which are the computers that forward e-mail messages to other connected computers.

Request For Comments (RFC) 822: Defines the format for the header of an e-mail message.

POP3: Helps to retrieve e-mail messages from the Internet and store the e-mail messages in the local computer of an end user.

SMTP: Helps to transfer e-mail messages across the Internet.

The IMAP Protocol

IMAP helps an e-mail message sender to create, delete, and rename mailboxes. IMAP provides three modes to process an e-mail message. The three modes are:

Offline: Allows a host to connect to a mail server and download the e-mail messages. The e-mail messages are then deleted from the mail server.

Online: Allows a host to read and delete the e-mail messages stored on the mail server. The host can request only a part of the e-mail message, such as the header or the body of the message. It is also possible to save an e-mail message on the host computer or the mail server. IMAP supports status flags, such as answered and deleted to mark the status of an e-mail message.

Disconnected: Allows the host computer to connect to a mail server. Instead of the e-mail message transfer from the server to the host computer, a copy of the e-mail message is stored on the host computer. This helps the host to reconnect to the server at a later time.

The MIME Protocol

MIME helps send different types of data, such a graphics file and a text file in a single e-mail message through the Internet. MIME provides the format of the data to the mail client of the message recipient. MIME uses the base64 encoding process to send an e-mail message containing data other than the text format.

Base64 encoding process uses three bytes and represents them as four characters in the ASCII standard. MIME converts arbitrary data present in an e-mail message to the text format before sending the message. MIME also decodes the e-mail message to its original form at the receiving end.

When you compose an e-mail message using a mail client program that supports MIME, the mail client program checks the format of the data in the e-mail message. The mail client uses MIME to provide the message format to the recipient mail client, if the e-mail message is in ASCII text format. On the other hand, MIME processes the e-mail message, if the e-mail message contains attachments and Hyper Text Markup Language (HTML) text format, in addition to ASCII text.

The mail client program determines the format of data and uses MIME to convert the data to the ASCII text format, if the data is other than the ASCII text format. The mail client inserts the encoded data in the e-mail message. The mail client program of the message recipient extracts and decodes the e-mail message.

The mail client program of the message recipient displays the attachments in an e-mail message with an attachment icon. The recipient can either save the e-mail message on the disk or open the message directly from the mail client program.

By default, the RFC 822 protocol transfers the text e-mail messages. MIME conforms to the standards defined by RFC 822. MIME adds the following headers to an e-mail message:

MIME-version: Specifies an e-mail message, which conforms to the MIME standards. This header helps an MTA to distinguish between the e-mail messages, which conform to the MIME and RFC 822 standards. You need to specify the parameter 1.0 with this header.

Content-type: Specifies the type of data contained in an e-mail message.

Content-Transfer-Encoding: Specifies the type of encoding scheme used to convert the data in ASCII text format. The various types of encoding schemes are 7bit, base64, 8bit, quoted-printable, and binary.

Content-ID: Helps to identify the various MIME entities. It is same as the message ID. You need to specify this header to identify the content-type of an e-mail message.

Content-Description: Provides the description about the contents of an e-mail message. It is optional to specify this header in an e-mail message.

The RFC 822 Protocol

The text messaging protocol, RFC 822, defines the following headers in an e-mail message:

Sender: Specifies the host from where an e-mail message is sent.

Receiver: Specifies the host where an e-mail message needs to be sent.

Trace: Provides information regarding the return path of an e-mail message.

Reference: Controls specific information about an e-mail message.

The various fields defined under the sender header are:

FROM/RESENT-FROM: Identifies the individual, computer name, or process on a host who wants to send an e-mail message. If this field does not contain information about the e-mail message sender, you can use the SENDER field to specify the message sender information.

SENDER/RESENT-SENDER: Specifies the name of the sender of an e-mail message. It is an optional field and the information in this field is same as that in the FROM field. The SENDER field specifies the name of the message sender instead of the mailbox from where the e-mail message was sent.

REPLY-TO/RESENT-REPLY-TO: Specifies the mailboxes where the replies to an e-mail message must be sent. In the absence of this field, the replies are sent to the address specified in the FROM field.

Note 

The RESENT fields are used when an e-mail message is forwarded. It specifies the original recipient of the e-mail message. For example, the RESENT-FROM field specifies the recipient that forwards the e-mail message.

The various fields defined under the receiver header are:

TO/RESENT-TO: Specifies the main recipient who receives the e-mail message.

CC/RESENT-CC: Specifies the recipients other than the main recipient who receive a copy of the e-mail message.

BCC/RESENT-BCC: Specifies additional recipients to whom a copy of the e-mail message is sent. The information in this field is not included in the copy of the e-mail message, which is sent to the recipients specified in the TO and CC fields.

The various fields defined under the trace header are:

RETURN-PATH: Specifies the return path through which the recipient MTA can return the e-mail message to the message sender.

RECEIVED: Specifies the path through which the e-mail message is delivered. This field contains information about the message sender and recipient and the time when the e-mail message was received.

The various fields defined under the reference header are:

MESSAGE-ID/RESENT-MESSAGE-ID: Specifies the version assigned to an e-mail message. If the message sender creates changed copies of an e-mail message, the e-mail messages will be assigned unique IDs.

IN-REPLY-TO: Specifies the host to which the message reply is being sent.

KEYWORD: Specifies keywords and phrases separated by a comma.

The POP3 Protocol

A POP3 protocol establishes a session between the POP3 server and the mail client program. Each POP session contains three stages, which are:

Authorization: Validates the mail client using the USER and PASS commands. The mail client uses a Transmission Control Protocol (TCP) connection to connect to the POP3 server and sends the USER command with the user name specified as a parameter. The mail client sends the PASS command with the password specified as a parameter, if the POP3 server returns the code, +OK. The POP3 session then enters into the transaction stage.

Transaction: Allows the mail client to view, download, and delete e-mail messages from the POP3 server. During this state, the mail client can issue various transaction commands, which are:

STAT: Retrieves the total number of e-mail messages and the number of bytes in each e-mail message.

LIST: Returns the size of each e-mail message stored in the mailbox of an end user, when the mail client specifies a parameter with the LIST command. The LIST command returns information about the specified e-mail message, when the mail client does not specify a parameter with this command.

TOP: Lists the headers and the first ten lines of an e-mail message.

NOOP: Checks if the POP3 server receives the mail client service requests or not.

RETR: Retrieves the specified e-mail message and sends the e-mail message to the mail client.

DELE: Marks an e-mail message that needs to be deleted.

RSET: Unmarks all the e-mail messages that were marked for deletion.

Update: Occurs when the mail client sends the QUIT command to the POP3 server. The QUIT command terminates the connection of the mail client with the POP3 server. When the POP3 session enters the update state, all the e-mail messages marked for deletion are deleted.

Note 

To learn more about the POP protocol, refer to Chapter 3.

The SMTP Protocol

MTA uses the SMTP protocol to transfer e-mail messages on the Internet. The e-mail transfer using the SMTP protocol is based on the mail transaction process. The sender MTA sends SMTP commands to initiate transaction with the receiver MTA. The sender MTA establishes a TCP connection with the receiver MTA and the receiver MTA sends a reply code 220 indicating that it is ready for the transaction.

After the connection to the receiver MTA is established, the sender MTA sends the HELO command with the mail client host as a parameter. The HELO command helps to identify and authenticate the mail client host addresses. The receiver MTA confirms the client host address and sends a reply code 250. The sender MTA starts the mail transaction process by using the MAIL command. The syntax of the MAIL command is:

MAIL <space> FROM:<reverse-path><CRLF>

In the above syntax:

<reverse-path>: Specifies the full reverse route through which the e-mail message is transferred. The reverse path continues from the current client host to the mailbox of an end user.

<CRLF>: Indicates the end of the mailbox address.

The receiver MTA transmits a reply code 550 if the client host address is unacceptable either because the mailbox is incorrect or not present. The sender MTA then sends the DATA command to the receiver MTA to indicate that the sender MTA is ready to send the e-mail messages. The receiver MTA provides a reply code 354 to indicate that it is ready to receive the e-mail messages. The data in an e-mail message is followed by a <CRLF>.<CRLF> sequence indicating that all the data has been transferred.

The receiver MTA sends a reply code 250 to acknowledge the receipt of the e-mail message. The sender MTA sends the QUIT command and the receiver MTA sends the reply code 221 to indicate that the mail transaction is complete.

Overview of Exchange Server and qmail MTA

MTA is a mail server program that enables transfer of e-mail messages from one computer to another. MTA uses the envelope information to identify the sender and recipient of each e-mail message and ensure that the e-mail message is in a correct format. MTA passes the e-mail message to an MDA, which delivers the e-mail message to the mailbox of an end user or another MTA.

Exchange Server requires TCP/IP to transfer an e-mail message from one computer to another on the network. Exchange Server does not use other network protocols to transfer the e-mail messages over a network. Active Directory provides the directory service for Exchange Server to store information about network objects and include information about the recipients in an e-mail system.

qmail is a secure, reliable, and efficient replacement for other MTAs, such as sendmail on UNIX hosts. This is because qmail has a modular architecture with small and simple code. It supports the POP3 and IMAP protocols so that you can use any mail client to send and receive e-mail messages. qmail uses LDAP to store the usernames and passwords at a centralized location. You can access this information using Lightweight Directory Access Protocol (LDAP). An open-source implementation of LDAP called OpenLDAP server provides a stand-alone LDAP server and libraries to implement LDAP.

Advantages and Disadvantages of Migrating from Exchange Server to qmail

The advantages of migrating from Exchange Server to qmail are:

qmail provides simple modules that work together to provide messaging functionality. qmail is platform-independent as it includes its own Input/Output (I/O) functions and string library functions. These library functions manipulate character strings, perform input and output, and manipulate dates and time in an e-mail message.

qmail modules communicate with each other using data structures, which do not require parsing. The process of parsing converts human-readable specifications into machine language form. Parsing is an error-prone process and attackers can have an unauthorized access to modules by exploiting bugs in the parsed code.

qmail offers better performance over Exchange Server because it uses multiple processes to deliver an e-mail message to multiple recipients. qmail is faster than Exchange Server and requires less time to deliver the messages because qmail does not have to wait for the lookups of the list of message recipients.

qmail performs message forwarding, aliasing, and mailing-list management using a single mechanism. Exchange Server uses separate mechanisms to perform all these functions.

qmail offers high flexibility as compared to Exchange Server. As the number of users increases, hardware resources need an upgrade, which requires high expenditure in Exchange Server.

qmail offers better relay controls and spam controls as compared to Exchange Server.

qmail is designed for hosts that have high-speed and network connectivity. qmail can use the serialmail package to operate on slow systems. In this case, qmail does not offer better performance as compared to other MTAs. The other disadvantages of qmail are:

Is difficult to configure and maintain.

Lacks help from trained experts, as it is a newly implemented product.

Needs to be build from source code.

Uses only the SMTP protocol to communicate with other qmail systems.

Handles addresses that are in the form, user@domain.

Conforms to RFC standards, as a result, the qmail systems that do not conform to these standards have difficulty in communicating with qmail-smtpd.

Cannot be distributed in binary form. It can be freely distributed in source code form.

Contains modular-based architecture, as a result, each module needs to be handled differently.

Changes can only be included in the qmail system only if they are absolutely required. This is because the qmail author does not allow any changes in the qmail system.

Comparing qmail to sendmail and Other UNIX MTAs

qmail is less complex than sendmail and includes features that are available in sendmail, such as virtual domains. You can easily understand the qmail source code and it is faster, better designed, and easy to configure as compared to sendmail. Also, the list of add-ons in qmail is shorter than that of sendmail. But, the installation of qmail requires various manual steps, which are automated in sendmail.

sendmail uses a separate MDA to deliver e-mail messages to the mailboxes stored in a central directory, such as /var/spool/mail or /var/mail. Alternatively, qmail uses built-in MDA to deliver e-mail messages to the mailboxes stored in the home directory of an end user.

sendmail documentation is better to qmail and includes sendmail books written by the author, Bryan Costales. There are several online tutorials, Frequently Asked Questions (FAQs), and other resources that provide sendmail documentation. By default, sendmail is configured with minimum security, which enables it to be used easily but makes it more vulnerable to attack.

Table 1-1 lists the comparison of qmail with other MTAs:

Table 1-1: Comparing qmail with Other MTAs

MTA

Security

Performance

Modular

qmail

High

High

Yes

postfix

High

High

Yes

sendmail

Low

Low

No

Exim

Low

medium

No

Migration Methodology

An end user may want to retain a log of all e-mail messages, which have been sent and received. When planning to migrate to qmail server, it is necessary to locate all stored data and ensure that the data is available even after the migration is complete. A migration methodology involves the following phases:

Data collection and project definition phase, which includes:

A description of the set of initial conditions including system architecture, applications and the data associated with them, protocols and standards used, and the physical environment, such as network bandwidth and location.

A description of the set of target conditions to which you need to migrate. Target conditions also include the same details as initial conditions.

A description of the method used to migrate from existing to the target conditions.

Justification for the chosen migration plan including the cost associated with the plan.

Pilot phase that tests the migration plan and justification provided for the plan.

Implementing the migration plan.

Monitoring the results of the migration plan.

To migrate mails, address books, and calendar services from Exchange Server to qmail server:

Implement OpenLDAP on Linux to centralize the e-mail system and network information. You can use the following command to check if OpenLDAP is installed on your Linux system or not:

#rpm -qa | grep openldap
openldap-devel-2.0.27-2.7.1
openldap-servers-2.0.27-2.7.1
openldap12-1.2.13-8

Migrate the Global Address Book (GAB) of Exchange Server to OpenLDAP server. For this, you need to convert GAB to Personal Address Book (PAB) of Outlook Express.

Note 

GAB contains the list of users and the groups to which they belong. You can use the address books, such as GAB and PAB to search for a user name and create and edit personal distribution lists.

Migrate mailboxes from Exchange Server to the qmail server. Migration of mailboxes is easy for mail clients, such as Outlook Express, because the e-mail messages are local to the desktop of an end user and the end user can access qmail using either IMAP or POP3 protocol.

Chapter 2: Overview of Exchange Server

Exchange Server is a messaging system provided by Microsoft that enables you to send and receive e-mail messages to and from the recipients. The recipients can be on a local server, on another server within the same organization, or on an external server, which supports messaging. Exchange Server supports messaging by using architecture components, such as system attendant, and transport components. Exchange Server also integrates with the Active Directory of the server operating system to centrally administer different objects of Exchange Server, such as mailbox of the recipients.

This chapter describes the architecture and transport components of Exchange Server. It also explains how an e-mail message is routed among the recipients within the same organization and recipients external to the organization. In addition, this chapter explains the various connectors used by Exchange Server to transfer the e-mail messages.

Architecture of Exchange Server

The architecture of Exchange Server is divided into modular components that perform tasks, such as storing information and transferring e-mail messages. The modular components are of two types, core and optional. The core components are automatically installed during the setup of Exchange Server. You need to install the optional components, such as connectors, separately to add additional features to Exchange Server. Connectors allow Exchange Server to connect to external messaging systems.

Exchange Server supports the following core components:

System Attendant: Controls the functioning of Exchange Server by performing various tasks, such as storing information pertaining to the route of an e-mail message.

Information Store: Stores the e-mail messages of the end users in a message database.

Message Transfer Agent (MTA): Routes the e-mail messages between the Exchange computers within a site and to MTAs in other sites. An Exchange computer is a computer that uses Exchange Server as its messaging system.

Note 

A site is a group of Exchange computers sharing the same directory and network connections.

Directory: Helps to centrally administer the information related to an organization and the configuration information of Exchange Server. This information is stored in a database called directory database.

Note 

An organization is an administrative unit of Exchange Server containing servers, which support messaging.

System Attendant

System attendant monitors and logs various Exchange Server processes, such as message tracking. The system attendant creates and maintains the routing table, and logs the information related to the e-mail message transfer, such as its route. This helps MTA to select the route for transferring an e-mail message. System attendant also logs information whether or not an e-mail message has successfully reached its destination.

Note 

A routing table stores the addresses of the network devices, such as gateways to route an e-mail message.

System attendant accesses the directory and MTA to perform various tasks, which are:

Generate e-mail addresses for new user accounts.

Send and receive e-mail messages for the link monitor.

Create routing tables for MTA.

Note 

Link monitors are programs that check the network connectivity to the server of a client by sending a test mail.

Information Store

The information store stores a single instance of the e-mail messages in a message database. The information store is of two types, private and public. The private information store, which is also called the mailbox store, stores the information in the mailboxes. Mailbox is accessible only to an individual end user of an organization to whom the mailbox belongs. The public information store, which is also called the public store, stores the information in the public folders. The public folders contain information in various forms, such as documents and messages. The information stored in public folders is accessible to all the end users of an organization.

You can use either one or both types of information store on a server. The performance of the server increases if the server has only one type of information store. This is because the server with one type of information store processes only one type of request, such as the request to access the mailbox or the public store.

End users can use the inboxes and folders in the Microsoft Office Outlook client application to retrieve an e-mail message stored in the information store. The sequence of actions performed by the information store on receiving a request form an end user to access an e-mail message is:

Searches the e-mail message in the memory cache.

Note 

Memory cache is a buffer in which the information store stores the most recently accessed e-mail messages. The memory cache saves the time to access the e-mail messages, which are read subsequently.

Searches the information store database, if an e-mail message is not in the memory cache.

Returns the requested e-mail message or the not found message to the requesting end user.

The sequence of actions performed by the information store, on receiving a request from a local user, to send an e-mail message is:

Resolve the individual addresses.

Log the e-mail message in the transaction log file of the information store.

Retrieves the e-mail addresses of a distribution list from the MTA, if the e-mail message is addressed to a group of end users.

Note 

A distribution list is a group of e-mail addresses that is used to send an e-mail message to all the e-mail addresses at one instance. When an e-mail message is addressed to a distribution list, the e-mail message is routed to all the e-mail addresses in the distribution list.

Transfer the e-mail message to the inbox of the recipient, if the recipient is on a local server. If the recipient is on a remote server, the e-mail message is transferred to the MTA of the local server, which forwards the e-mail message to the remote MTA of the remote recipient server.

The information store records each transaction of the information store in a log file. The log file helps to retrieve the changes made to the information store, in case of a server failure.

Message Transfer Agent

MTA routes the e-mail messages to its recipients, which can be on the same site or on different sites. MTA works together with the directory, information store, and system attendant to route an e-mail message to its recipient. The directory provides the address information to MTA, for performing tasks, such as expanding the distribution lists. The system attendant helps to track the e-mail messages by logging the information in log files about the e-mail messages sent by MTA.

The sequence of actions performed by MTA to route an e-mail message is:

Store the e-mail message in a queue in the MTA database, which is a memory cache.

Determine the location, where the e-mail message is to be transferred, using the directory.

Route the e-mail message to the information store, if the recipient is on the local server. MTA can also route the e-mail message to the other MTA of the remote recipient server.

Delete the e-mail message from the MTA database after routing the e-mail message.

MTA changes the format of the e-mail messages from the Microsoft Database Exchange Format (MDBEF) to the Interpersonal Message (IPM) format. The translation of an e-mail message form the MDBEF format to the IPM format helps the Exchange Server clients to exchange e-mail messages with the recipients based on X.400 messaging systems.

Note 

X.400 messaging system is a messaging system that is based on the X.400 standard. X.400 is a standard for e-mail messaging similar to the SMTP protocol.

MDBEF is a proprietary format of Microsoft that is used by the information store and MTA to transfer the e-mail messages internally. If the e-mail messages are to be transferred to a different messaging system, then the MDBEF format messages are translated into a different format, such as IPM. The IPM format divides an e-mail message into two parts, envelope and content. The envelope part contains the information required for delivering an e-mail message, such as the address of the sender and the recipient. The content part contains the text of the e-mail message.

Directory

The directory of an Exchange Server functions as a directory database and directory service. The directory database stores the information about the various objects in an organization, such as distribution lists, e-mail addresses, mailboxes, and public folders, and the configuration information about the sites and servers. The directory service provides access to the information stored in the directory database.

You can use the Administrator program of Exchange Server 5.5 or Active Directory of Exchange Server 2003 to configure the information stored in the directory of Exchange Server. After you configure the objects of an organization, the directory information is automatically replicated among the servers sharing the same site. This replication helps each server in a site to access the current information about the object of an organization.

MTA uses the directory service to retrieve the e-mail addresses from the directory database. The sequence of actions performed by the directory service, to retrieve the e-mail address is:

Search the memory cache for the requested address.

Search the directory database, if the address is not present in the memory cache.

Return the requested address or a not found message to the requesting client.

The directory database stores the recently accessed e-mail addresses in a memory cache to reduce the time required to access the information.

Exchange Server and Active Directory

Exchange Server 5.5 and its earlier versions use the directory to store the configuration information of the Exchange Server, distribution lists, mailbox, and the information about recipients. The later versions of Exchange Server, such as Exchange Server 2003 do not contain a directory and use Active Directory of the server operating system, such as Windows Server 2003. Active Directory stores the configuration information of the Exchange Server and other information, such as information about the mailbox of the recipient.

Active Directory helps to centrally administer all the objects of an organization. Exchange Server uses the components of the system attendant, such as DSAccess and DSProxy, to retrieve the information from Active Directory.

You can migrate the directory objects from Exchange Server 5.5 into Active Directory using Active Directory Connector (ADC). ADC migrates the directory objects on the basis of the following Connection Agreements:

Recipient Connection Agreement (RCA): Replicates the mailboxes, distribution lists, and Custom Recipient directory objects between Exchange 5.5 directory and Active Directory.

Public Folder Connection Agreement (PFCA): Replicates the public folder directory objects between the Exchange 5.5 directory and the Active Directory.

Configuration Connection Agreement (Config_CA): Replicates the configuration information of the organization and site.

Active Directory stores the information related to Exchange Server in different directory partitions. The various directory partitions are:

Domain: Stores information about the recipients and system objects of the Exchange Server.

Configuration: Stores the configuration information related to the Exchange Server, such as administrative groups, recipient policies, system policies, and address lists. The information stored in the configuration directory partition is replicated to all the domain controllers in the forest.

Schema: Stores the schema information of Exchange Server, such as classes and attributes. The information stored in the schema directory partition is replicated to all the domain controllers in the forest.

Note 

Exchange Server uses various classes, such as user, group and contact. These classes store different information, such as username and group name in the from of attributes.

Storage Architecture of the Exchange Server

The storage architecture specifies the way Exchange Server stores the e-mail messages in a message database. The storage architecture of Exchange Server contains two types of files, .edb and .stm. The .edb file stores the contents of the Messaging Application Programming Interface (MAPI) e-mail messages and the metadata related to the e-mail messages. The .stm file stores the Internet content, such as e-mail message body, which is in the native format. The default mailbox store uses the Priv1.edb and Priv1.stm files, and the default public store uses the Pub1.edb and Pub1.stm files. The default mailbox store and the default public store are automatically created when you install an Exchange Server.

The transactions made to the database are recorded in the transaction log files to roll back the changes, if a failure occurs before committing the changes. All the transaction log files and checkpoint files are stored at a single location, called storage group, in the memory of Exchange Server.

Note 

A checkpoint file contains information about the transactions to be committed to the database files of an Exchange Server.

The different versions of Exchange Server use several types of log files. The log files used in Exchange Server 2003 are:

<Log Prefix>xxx.chk: Specifies a checkpoint file, which determines the transactions to be updated to the database.

Exx.log: Specifies a log file, which stores the current transactions related to the storage group.

<Log Prefix>XXXXX.log: Specifies the files, which have no memory space left to store more data.

Res1.log and Res2.log: Specifies the reserved log files for storing the transactions related to the storage group. The reserved log files store the transactions if the disk of the server is full.

Routing Components

Exchange server uses routing to deliver an e-mail message within the same organization or over the Internet. Routing determines the most efficient path through which an e-mail message is to be sent.

Routing of an e-mail message is performed on the basis of routing topology, which uses routing components to provide the path to transfer an e-mail message. The various routing components are:

Transport components: Specify the components, such as routing engine, that help to send and receive the e-mail messages.

Connectors: Specify paths between different routing groups through which an e-mail message is transferred.

Transport Components

The transport components of Exchange Server help to transfer an e-mail message from a sender to the recipient. The various transport components of Exchange Server are:

Routing engine

Advanced queuing engine

Message categorizer

The routing engine is an Exchange service provided by Exchange Server for routing an e-mail message to different locations. The routing engine determines the most efficient path through which an e-mail message is to be routed. The routing engine then passes this information to the advanced queuing engine for delivering the e-mail messages to the recipients.

The advanced queuing engine performs various functions, such as storing the e-mail message in a queue. The advanced queuing engine performs the following sequence of actions:

Retrieves the e-mail message from the Simple Mail Transfer Protocol (SMTP).

Determines the destination of the e-mail message, such as local store or MTA with the help of the message categorizer.

Stores the e-mail message in an appropriate queue before it is delivered to the recipient.

The message categorizer performs directory lookups to retrieve the information about a recipient, such as e-mail address, mailbox store, and Exchange Server containing the mailbox store. The message categorizer uses Lightweight Directory Access Protocol (LDAP) to retrieve the information.

Note 

LDAP is a protocol that helps to access the information directories, such as the Active Directory of Windows server operating system.

Connectors

Connectors are gateways that route the e-mail messages both within the organization and to the foreign messaging systems. The connectors help in routing the e-mail message within the organization by creating one or more instances of a connector. Each connector has an associated address space, which is used by MTA to select the connectors for routing a specific e-mail message.

The various connectors used by Exchange Server are:

Routing group connectors

SMTP connectors

X.400 connectors

Additional connectors

Routing Group Connectors

The routing group connector creates a unidirectional connection, which helps to connect the routing groups. The routing group connector connects a server in one routing group to another server in different routing group. The routing group connector uses the bridgehead server to transfer the e-mail messages between different routing groups, and SMTP as the transport protocol.

Note 

Bridgehead server is an Exchange computer that acts as an endpoint of a connection between two sites, and routes the e-mail messages through that connection.

The routing group connectors can also connect an Exchange 2000 routing group with an Exchange 5.5 site to exchange the e-mail messages. You can configure a routing group connector to support zero or more bridgehead servers.

The use of different number of bridgehead servers affects the way an e-mail message is transmitted:

Zero bridgehead servers: Causes all the servers in a routing group to become bridgehead servers for transmitting an e-mail message.

One bridgehead server: Causes all the e-mail messages to flow through the defined bridgehead server. This helps an administrator to track the flow of e-mail messages.

Multiple bridgehead servers: Helps a routing group in load balancing by allowing the Exchange server to use another bridgehead server, if one bridgehead server fails.

You can access the properties dialog box of a routing group connector by right clicking its icon on the tree view of the Exchange System Manager window and selecting properties from the context menu. You can open the Exchange System Manager window by selecting Start -> Programs -> Microsoft Exchange -> System Manager.

Figure 2-1 shows the properties dialog box for a routing group connector, First that helps to configure the routing group connector:

Click To expand: This figure shows the options in the General tab of the First Properties Dialog Box.
Figure 2-1: The First Properties Dialog Box for Routing Group Connector

The various configuration options for routing group connector are categorized on the basis of various tabs in the routing group connector properties dialog box. The various tabs on the routing group connector properties dialog box are:

General: Helps to specify the cost of the connector on a scale of 1 and 100. This cost helps to select the path of the connector when multiple paths exist between the source and the destination. You can also prevent the end users from making public folder references through this connector.

Remote Bridgehead: Helps to specify the bridgehead server in the routing group to which the connector is connecting.

Content Restrictions: Helps to specify the priority, such as High, Normal, or Low, and the type, such as System messages and Non-system messages of the e-mail messages that can be delivered through the connector.

Delivery Restrictions: Helps to specify the senders from which to accept or reject the e-mail messages. By default, the e-mail messages from all senders are accepted.

Delivery Options: Helps to specify the time when the e-mail messages can be sent through the connector. You can also specify a schedule for delivering an e-mail message on the basis of its size.

Details: Helps to view the creation and last modification date of the connector.

SMTP Connectors

The SMTP connectors connect the external mail systems to the Exchange server. You can configure an SMTP connector with the help of the SMTP connector properties dialog box. An SMTP connector allows you to configure various options with the help of different tabs in the SMTP connector properties dialog box. You can access the properties dialog box of an SMTP connector by right clicking its icon on the tree view of the Exchange System Manager window and selecting properties from the context menu.

Figure 2-2 shows the General tab of the properties dialog box for an SMTP connector, First:

Click To expand: This figure shows various options, such as the Do not allow public folder referrals option of the General tab of the First Properties dialog box.
Figure 2-2: The First Properties Dialog Box

The various tabs of the SMTP connector properties dialog box are:

General: Helps to specify a name for the SMTP connector. The General tab also helps to configure the delivery of the e-mail messages through Domain Name System (DNS) or through a smart host. You can also add or remove the local bridgehead servers for the SMTP connector by using the Add or Remove button on the General tab.

Address Space: Helps to configure an address space. You can also select the scope of a connector to specify, which e-mail messages can flow through this connector. The Entire organization option on the Address Space tab helps to make the connector available to the entire organization for transferring the e-mail messages. You can also enable the relaying of e-mail messages through the SMTP connector to the address spaces specified in the Address Space tab. By default, the relaying of the e-mail messages to these address spaces is blocked.

Connected Routing Groups: Helps to create, modify, or remove a routing group connected to your routing group through the connector. All the connected routing groups must be in the same organization.

Delivery Restrictions: Helps to accept or reject the e-mail messages of the senders by specifying their addresses.

Delivery Options: Helps to specify the time interval for which e-mail messages can be sent through the connector. You can also specify different time intervals for delivering specific e-mail messages on the basis of the message size.

Content Restrictions: Helps to specify the priority of the messages, such as High or Normal, and the type of the messages, such as System messages or Non-system messages, delivered through the connector. You can also specify the maximum size for an e-mail message sent through the connector.

Advanced: Helps to select the command used by the SMTP connector to send the e-mail messages. You can also configure the use of TURN and ETRN commands by the client hosts. The TURN and ETRN commands allow the client hosts to send dequeuing requests. You can use this tab to specify the number of times the e-mail messages are de-queued, if the TURN and ETRN commands are enabled.

Details: Helps to view the date and time of creation and last modification of the SMTP connector.

X.400 Connectors

The X.400 connectors transfer the e-mail messages within the routing group, and between two routing groups within the same organization. You can also use the X.400 connector to transfer e-mail messages between an Exchange routing group and a X.400 foreign messaging system. The X.400 Connector has less bandwidth requirement in comparison to other connectors.

The various types of X.400 connectors are:

TCP/IP X.400 connectors: Transfer e-mail messages over a standard TCP/IP network.

RAS X.400 connectors: Use the Windows 2000 Remote Access Services (RAS) for transferring e-mail messages.

X.25 X.400 connectors: Connect to an X.25 adapter on a remote mail server and support standard X.25 protocols.

Each X.400 connector type has a corresponding stack, called transport stack, to store the information required for transferring an e-mail message. The various available transport stacks are the TCP/IP X.400 stack, the RAS X.400 stack, and the X.25 X.400 stack. The X.400 transport stack that you configure should be of the same type as its connector. You can use the Exchange System Manager window to create a transport stack and its corresponding connector.

You can access the properties dialog box of TCP/IP X.400 transport stack by right clicking its icon on the tree view of the Exchange System Manager window and selecting properties from the context menu.

Figure 2-3 shows the TCP Properties dialog box for TCP/IP X.400 transport stack that helps to configure the TCP/IP X.400 transport stack:

Click To expand: This figure shows the various options, such as Name and OSI address information in the General tab of the TCP Properties dialog box.
Figure 2-3: The TCP Properties Dialog Box

The various configuration options for the TCP/IP X.400 transport stack are categorized on the basis of the various tabs in the TCP Properties dialog box. The various tabs on the TCP Properties dialog box are:

General: Helps to specify the name and Open Systems Interconnection (OSI) address of the TCP/IP X.400 transport stack.

Connectors: Display various connectors that use this TCP/IP X.400 transport stack.

Details: Display the creation and last modified date and time of the TCP/IP X.400 transport stack.

You can access the properties dialog box of a TCP connector by right clicking its icon on the tree view of the Exchange System Manager window and selecting properties from the context menu.

Figure 2-4 shows the First TCP Connector Properties dialog box:

Click To expand: This figure shows the General tab of the First TCP Connector Properties dialog box that helps to select the X.400 transport stack.
Figure 2-4: The First TCP Connector Properties Dialog Box

The various configuration options for the TCP/IP X.400 connector are categorized on the basis of various tabs in the TCP Connector Properties dialog box. The various options on the TCP Connector Properties dialog box are:

General: Helps to specify the name of the connector and the name of the remote server to which the connector is connecting. You can also use the General tab to configure the connector to send the e-mail messages with rich-text characters, such as bold and italic. The General tab also prevents the end users from making public folder references through this connector. By default, all servers in the connected routing group can access the public folder.

Schedule: Helps to create schedules, which specify the time when you to want the connector to perform the tasks.

Stack: Helps to specify the address of the remote X.400 system to which the connector connects.

Override: Helps to change the attributes of the X.400 stack for a specific connector. The attributes changed for one connector do not affect the process of e-mail message transfer to other connectors.

Address Space: Helps to create, modify, or remove an address space. You can also specify the scope of the connector through this tab, such as Routing group, or Entire organization.

Connected Routing Groups: Helps to add, modify, or remove the routing groups connected to your routing group through this connector. Each connected routing group is specified with an administrative group name and a routing group name.

Content Restrictions: Helps to specify the priorities, such as High, Normal, or Low for the e-mail messages delivered through this connector. You can also specify the type of messages that are delivered through this connector, such as System messages, Non-system messages, or both. You can also specify the maximum size of the e-mail messages delivered through this connector.

Delivery Restrictions: Helps to specify the senders from which to accept or reject the e-mail messages. By default e-mail messages from all senders are accepted.

Advanced: Helps to select the format of the text used by an e-mail message. The format must be supported by the foreign system to which an e-mail message is being delivered. You can also specify the X.400 conformance to 1984, 1988 X.410 mode, or 1988 normal mode recommendations. The default conformance is to the 1988 normal mode recommendations.

Details: Helps to view the creation and last modification date of the connector.

Additional Connectors

You can use the additional connectors to connect the Exchange Server messaging systems to different messaging systems, such as Lotus cc:Mail. The various additional connectors are:

Site Connector: Helps to connect two Exchange Server sites.

Internet Mail Service: Helps to connect different sites in an organization and to route e-mail messages over the Internet.

Microsoft Exchange Connector for Lotus cc:Mail: Helps the Exchange Server and Lotus cc:Mail systems to share the directory and transfer the e-mail messages with each other.

Microsoft Mail Connector: Helps to connect Microsoft Mail on PC Networks with Microsoft Mail on AppleTalk Networks.

Introducing SMTP

SMTP is a protocol that helps to transfer the e-mail messages across the networks. Exchange server uses SMTP to transfer the e-mail messages between Exchange Servers and the routing groups. SMTP also transfers the e-mail messages to the servers that are external to the organization.

Note 

Routing groups specify a logical group of servers that send e-mail messages directly to each other or to the servers in another routing group.

Transport Dependencies of SMTP

The transport dependencies of SMTP specify the various features and services on which SMTP is dependent, for transferring the e-mail messages across the networks.

The various transport dependencies of SMTP are:

Internet Information Services: Provide the World Wide Web Publishing service, SMTP service, and the Network News Transfer Protocol (NNTP) service.

Active Directory: Stores the configuration information of Exchange Server, such as recipient policies and SMTP server configuration. It also stores the information about the routing topology, such as routing groups and bridgehead servers.

Domain Name System: Provides the Internet Protocol (IP) address of the server, where the e-mail message is to be sent.

Recipient policies: Determine the format of the e-mail addresses used in an Exchange system, such as X.400 addresses.

Recipient Update Service: Updates the Active Directory with the information, such as e-mail address, pertaining to a new recipient.

Directory service to metabase service (DS2MB): Replicates the information from Active Directory to the Internet Information Services (IIS) metabase.

SMTP Virtual Server

An SMTP virtual server is an instance of the SMTP service provided by IIS. An SMTP virtual server is identified by an IP address and a port number.

The various configuration options for an SMTP virtual server are categorized on the basis of the various tabs in SMTP Virtual Server Properties dialog box. The various tabs on the SMTP Virtual Server Properties dialog box are:

General

Access

Messages

Delivery

The SMTP virtual server can be configured to receive inbound e-mail messages on its IP address and its configured port, which is 25 by default. You can configure the port and IP address of the SMTP virtual server using the options available in the General tab of the SMTP Virtual Server Properties dialog box. You can access the properties dialog box of SMTP virtual server by right clicking its icon on the tree view of the Exchange System Manager window and selecting properties from the context menu.

Figure 2-5 shows the General tab of the default SMTP Virtual Server Properties dialog box:

Click To expand: This figure shows the options in the General tab of the SMTP Virtual Server Properties dialog box.
Figure 2-5: The General Tab of the Default SMTP Virtual Server Properties Dialog Box

You can use the General tab of the SMTP Virtual Server Properties dialog box to perform the following tasks:

Specify the TCP/IP port and create multiple identities for the SMTP virtual server.

Identify the maximum number of connections that can be made with the SMTP virtual server.

Specify the time in minutes before an inactive client is disconnected, which is 10 minutes by default.

Create log of transactions in the log files.

You can configure the security, access, and relay options for the SMTP virtual server using the Access tab of the SMTP Virtual Server Properties dialog box.

Figure 2-6 shows the Access tab of the default SMTP Virtual Server Properties dialog box:

Click To expand: This figure shows the various buttons, such as Connection and Relay in the Access tab of Default SMTP Virtual Server Properties dialog box.
Figure 2-6: The Access Tab of the Default SMTP Virtual Server Properties Dialog Box

The Access tab divides its configurable options into the following categories:

Access control: Helps to select the authentication method, such as Anonymous access or Basic authentication that authenticates the client accessing the SMTP virtual server.

Secure communication: Helps to create the X.509 server certificate, which secures the communication between the client and the SMTP virtual server.

Connection control: Helps to grant or deny the SMTP virtual server access to the specific IP addresses or subnet masks.

Relay restrictions: Helps to restrict the specific end users from relaying the e-mail messages through the SMTP virtual server.

You can also restrict the specific internal end users or groups from sending e-mail messages through the SMTP virtual server by using Discretionary Access Control List (DACL), provided by Windows 2000 Server and Windows Server 2003.

Note 

A DACL is a list of end users and groups, and their access permissions.

You can configure various options pertaining to the transfer the e-mail messages using the Messages tab of the SMTP Virtual Server Properties dialog box.

Figure 2-7 shows the Messages tab of the default SMTP Virtual Server Properties dialog box:

Click To expand: This figure shows the options available on the Messages tab of the SMTP virtual server properties dialog box.
Figure 2-7: The Messages Tab of the Default SMTP Virtual Server Properties Dialog Box

The various options available on the Messages tab of the SMTP virtual server properties dialog box are:

Limit message size to (KB): Specifies the maximum size of an e-mail message.

Limit session size to (KB): Specifies the total size of the e-mail messages that can be simultaneously transferred through the SMTP virtual server.

Limit number of messages per connection to: Specifies the maximum number of e-mail messages that can be transferred in one session. The default value is 20.

Limit number of recipients per message to: Specifies the maximum number of recipients to which an e-mail message can be addressed. If the number of recipients to which an e-mail message is addressed exceeds its limit, Exchange Server sends a Non-Delivery Report (NDR) to the sender. The default value is 64000.

Send copy of Non-Delivery Report to: Specifies an e-mail address to which a copy of each NDR is delivered. By default, the NDR is delivered only to the sender of the e-mail address.

Badmail directory: Specifies the path of the folder in which the undelivered e-mail messages are stored. You can also use the Browse button to browse the location of the folder.

Queue directory: Specifies the path of the queue directory of the SMTP virtual server. The queue directory contains all the queues used by the SMTP virtual server.

Forward all mail with unresolved recipients to host: Specifies the Fully Qualified Domain Name (FQDN) of an alternate SMTP virtual server to which all the undelivered e-mail messages are forwarded, so that they can be delivered again. If the SMTP virtual server again fails to deliver the e-mail message, it issues an NDR.

The Delivery tab of the SMTP Virtual Server Properties dialog box provides various configurable options related to the local and outbound delivery of the e-mail messages.

Figure 2-8 shows the Delivery tab of the default SMTP Virtual Server Properties dialog box:

Click To expand: This figure shows the various options on the Delivery tab of the SMTP Virtual Server Properties dialog box.
Figure 2-8: The Delivery Tab of the Default SMTP Virtual Server Properties Dialog Box

The controls on the Delivery tab of the SMTP Virtual Server Properties dialog box are:

Outbound frame: Provides various options related to the delivery of outbound messages, such as:

First retry interval (minutes): Specifies the first time interval in minutes, after which the SMTP virtual server attempts to deliver the outbound message again.

Second retry interval (minutes): Specifies the second time interval in minutes after which the SMTP virtual server attempts to deliver the outbound message again.

Third retry interval (minutes): Specifies the third time interval in minutes after which the SMTP virtual server attempts to deliver the outbound message again.

Subsequent retry interval (minutes): Specifies the time interval in minutes after which the SMTP virtual server attempts to deliver the outbound message again after the third retry.

Delay notification: Helps to specify the time period after which the senders are notified about the delay in the delivery of an e-mail message.

Expiration timeout: Helps to specify the time period after which the SMTP virtual server stops its attempts to deliver the e-mail message.

Local frame: Provides various options pertaining to the delivery of local messages, such as Delay notification and Expiration timeout.

Outbound Security button: Helps to specify the type of authentication, such as Anonymous access or Basic authentication that is used by the SMTP virtual server while delivering an e-mail message to the other SMTP virtual server.

Outbound connections button: Helps to specify the various options related to the outbound connections, such as:

Limit connections to: Specifies the total number of outbound connections that an SMTP virtual server can create.

Time-out: Specifies the time period in minutes after which the SMTP virtual server terminates a connection, when the other SMTP virtual server is not responding.

Limit connections per domain to: Helps to specify the maximum number of outbound connections that an SMTP virtual server can establish with a domain.

TCP port: Helps to specify the Transmission Control Protocol (TCP) port that is used by the SMTP virtual server to establish outbound connections. The default port is 25.

Advanced button: Helps to configure various advanced options pertaining to the delivery of e-mail messages, such as the maximum number of hops that an e-mail message can take before it is delivered.

Inbound Message Flow Through SMTP

The sequence of actions performed by the SMTP virtual server to receive an inbound message is:

The SMTP virtual server creates a message structure called IMAILMSG for the inbound message.

The SMTP virtual server stores both IMAILMSG and the e-mail message in a Queue directory.

The e-mail message is then sent to the advance queuing engine, which stores the e-mail message in the pre-categorizing queue (PreCatQueue).

Note 

PreCatQueue is a queue that stores all the e-mail messages, which are to be routed.

The advance queuing engine then sends the e-mail message to the message categorizer.

The message categorizer determines the destination of the e-mail message, such as the local store, MTA, or the SMTP engine, and returns the e-mail message to the advanced queuing engine.

The advanced queuing engine stores the e-mail message in the pre-routing queue (PreRoutingQueue), determines the route through which the e-mail message is to be sent, and sends the message destination to the routing engine.

Note 

PreRoutingQueue is a queue that stores the e-mail messages for which the route is yet to be determined.

The routing engine determines the next hop for the message destination.

The queuing engine retrieves the information about the message destination from the message categorizer and the routing information from the routing engine. The e-mail message is then delivered using one of the two ways:

Exchange store driver delivers the e-mail message to the information store, if the message destination is in a local domain.

The e-mail message is passed to SMTP to be delivered as an outbound message, if the message destination is a remote domain.

Note 

The IMAILMSG structure is deleted after the e-mail message is successfully delivered.

Figure 2-9 shows the inbound message flow through the SMTP virtual server:

Click To expand: This figure shows how an inbound message is delivered with the help of advanced queuing engine and message categorizer.
Figure 2-9: Inbound Message Flow

Outbound Message Flow Through SMTP

The SMTP virtual server helps send the outbound messages to the recipients. The sequence of actions performed when an outbound message is sent by an SMTP virtual server, is:

The client forwards the e-mail message that is to be delivered to the information store.

The information store moves the e-mail message to a folder called SendQ.

The store driver retrieves the e-mail message from the SendQ folder, constructs IMAILMSG, and sends the e-mail message to the advanced queuing engine.

The route and destination for the e-mail message is determined with the help of message categorizer and routing engine.

The advanced queuing engine sends the e-mail message to its destination.

Figure 2-10 shows the outbound message flow through the SMTP virtual server:

Click To expand: This figure shows how an outbound message is delivered from the information store to the destination of the e-mail message.
Figure 2-10: Outbound Message Flow

Message Routing

Exchange Server routes the e-mail messages between recipients on the same server, same routing group, different routing group, and on a server external to the Exchange organization. Message routing performs the following functions:

Determines the next hop for the e-mail message on the basis of the most efficient path.

Exchanges the link state information among the routing groups. The link state information specifies whether or not the servers can communicate with each other.

Message Routing Within the Same Server

When both the sender and the receiver are on the same server, the e-mail message is routed within the same server. The e-mail message of the sender is delivered to the recipient through the mailbox in the local store of the server.

Figure 2-11 shows the routing of an e-mail message between the end users residing on the same server:

Click To expand: This figure shows the routing of an e-mail message from the computer of a sender to the Exchange Server, and from the Exchange Server to the computer of a recipient.
Figure 2-11: Message Routing on the Same Server

Message Routing Within the Same Routing Group

An e-mail message is routed within the same routing group when the recipient resides on a different Exchange Server within the same routing group. Different versions of Exchange Server use different protocols for transferring the e-mail message. For example, Exchange Server 5.5 uses the Remote Procedure Call (RPC) protocol and the Exchange 2000 Server uses the SMTP protocol.

Note 

The RPC protocol is a protocol that is used for remote communication. The RPC protocol enables the end users to make remote procedure calls to access the resources of the remote computer.

Figure 2-12 shows the routing of an e-mail message between the end users residing on the same routing group:

Click To expand: This figure shows the routing of an e-mail message between the sending and receiving servers within the same routing group.
Figure 2-12: Message Routing in the Same Routing Group

Message Routing to a Different Routing Group

When an e-mail message is routed to a different routing group the Exchange Server of the sender verifies the link state information and determines a route through which the e-mail message is to be sent. After determining the route, Exchange Server sends the e-mail message to the connector connected to the routing group of the recipient, or to the next routing group in the determined route.

Figure 2-13 shows the routing of an e-mail message, when the sender and the recipient are in the different routing groups:

Click To expand: This figure shows the transferring of an e-mail message between a sender and a recipient that are on different routing groups.
Figure 2-13: Message Routing to a Different Routing Group

Message Routing to an External Organization Server

An e-mail message is routed to the server of an external organization, if the recipient belongs to an external organization or a foreign messaging system.

Note 

A foreign messaging system refers to a messaging system other than Exchange Server.

The sequence of actions performed by Exchange Server to send the e-mail messages to an external organization is:

Exchange Server determines the connector for sending the e-mail message.

Exchange Server sends the e-mail message to the routing server on the routing group of the Exchange Server.

The routing server forwards the e-mail message to the connector.

The connector delivers the e-mail message to its recipient.

Figure 2-14 shows the routing of the e-mail message, when the sender and the recipient are in different Exchange organizations or messaging systems.

Click To expand: This figure shows the routing of an e-mail message through intermediate routing servers and connectors.
Figure 2-14: Message Routing to an External Organization Server

Chapter 3: Overview of qmail

qmail is a Mail Transfer Agent (MTA) for Unix, Linux, and Solaris operating systems. qmail accepts e-mail messages from a Mail User Agent (MUA), such as Outlook Express, Eudora, and Pine and the mail delivery method used by qmail depends on the name and address of the message sender and recipient. qmail transfers e-mail messages to an Mail Delivery Agent (MDA) for mail delivery. An MDA accepts an e-mail message from an MTA and delivers the message to the recipient. An end user is not required to interact directly with qmail, instead the end user uses an MUA.

qmail improves system performance by using multiple small modules to transfer a single e-mail message in minimum time. qmail is more reliable than other MTAs, such as sendmail, postfix, and exim because it ensures that the message is delivered to the recipient even if power failure occurs. qmail can deliver several messages simultaneously at a high speed using less memory space without affecting the reliability of the MTA.

This chapter describes the architecture and working of qmail. It explains the process of mail delivery and types of file formats available in qmail. In addition, it describes the various methods used to obtain qmail help including qmail documentation and mailing lists.

Exploring qmail

qmail contains various modules, which interact with each other to transfer e-mail messages. qmail modules are divided into two categories to send and receive e-mail messages. One set of modules accepts e-mail messages and places them in a queue. Another set of modules delivers the e-mail messages stored in the queue.

Architecture of qmail

qmail has a modular system architecture, where a separate program or module is used to perform different function, such as queue management and mail delivery. The modules that accept e-mail messages and place them in the queue are:

qmail-smtpd: Accepts or rejects e-mail messages through the use of Simple Mail Transfer Protocol (SMTP).

qmail-queue: Places an e-mail message in the queue.

qmail-inject: Creates an e-mail message and uses the qmail-queue module to place the e-mail message in the queue.

Another category includes the modules that deliver the messages placed in the queue. These modules are:

qmail-rspawn/qmail-remote: Handles the e-mail messages that are delivered to a remote end user.

qmail-lspawn/qmail-local: Handles the e-mail messages that are delivered to a local end user.

qmail-send: Processes the e-mail messages placed in the queue.

qmail-clean: Cleans the queue by removing all the message files from the queue.

Figure 3-1 shows how the various qmail modules are connected to each other:

Click To expand: This figure shows the interconnection between different qmail modules.
Figure 3-1: Interconnection of qmail Modules

The qmail-queue module is invoked from other modules, such as the qmail-inject and qmail-smtpd modules, to add the e-mail messages directly to the queue. The qmail-send module maintains the list of e-mail messages, which are to be delivered. It also retrieves the failed mail deliveries.

The qmail-send module processes the e-mail messages stored in the queue and dispatches them to the qmail-lspawn and qmail-rspawn modules. The qmail-lspawn and qmail-rspawn modules dispatch local and remote message deliveries. After the qmail-send module delivers an e-mail message, the qmail-clean module removes the message files from the queue.

Each e-mail message can be delivered either to a local host or a remote host. Local message delivery occurs to end users, mailboxes, and addresses on the same server from where the e-mail message originates. Remote message delivery occurs to addresses on other servers through SMTP.

qmail files are stored in the /var/qmail directory. The various subdirectories under /var/qmail are:

alias: Contains the .qmail files for system aliases. An alias is a hostname that replaces another hostname. For example, the alias for recipient.example.com can be www.example.com.

bin: Contains the binary and script files to configure and run qmail.

boot: Contains the script files necessary for qmail startup.

control: Contains qmail configuration files.

doc: Contains qmail documentation except man pages.

man: Contains man pages.

queue: Contains the list of unsent messages.

users: Contains a database of end users who use qmail.

Note 

Man pages provide description of the Unix commands by using the man command followed by the command, the description of which you need to view.

The various subdirectories in the queue subdirectory are:

bounce: Contains permanent errors related to mail delivery.

info: Contains the addresses of message sender.

intd: Contains the list of envelopes that the qmail-queue module processes. An envelope specifies the name and address of the e-mail message sender and recipient.

local: Contains the addresses of the recipients who are located on local computer.

lock: Contains lock files that indicate whether the operations on a file are restricted or not.

mess: Contains the message files.

pid: Provides an inode number to the qmail-queue module. An inode number is a unique number associated with each file name.

remote: Contains the remote recipient addresses.

todo: Contains the list of envelopes.

Note 

You can use the inode number to search an entry in the inode table, which contains information about the type, size, location, and user ID of the owner of the file.

If the host name of the recipient address is present in the control or the locals file, the e-mail message is delivered locally. Otherwise, the message is delivered to a remote mail system.

Working of qmail

qmail accepts e-mail messages either from a local server or from the network through SMTP. Each e-mail message contains three components:

Envelope: Is used to perform message transaction between MTAs. The syntax of the envelope format is:

Fsender^@Trecip^@Trecip....^@^@

In the above syntax:

^@: Specifies a zero byte.

Fsender: Specifies the address of the e-mail message sender.

Trecip: Specifies the address of the e-mail message recipient.

Header: Specifies the name and address of the e-mail message sender and recipient and additional information, such as date, subject, and mail delivery details.

Body: Contains the message data.

The qmail-queue module uses the envelope information to transfer an e-mail message into qmail. All the local or remote programs that generate e-mail messages use the qmail-queue module to queue the messages and schedule them for delivery.

Figure 3-2 shows the working of qmail:

Figure 3-2: Working of qmail

The qmail-queue module inserts e-mail messages in the queue in four stages, which are:

Creates a pid file in the /var/qmail/queue/pid directory. The file system assigns an inode number to the file. The inode number represents the queue ID for the message.

Renames the pid file to an inode file and stores the inode file in the mess/split/inode directory.

Writes the message text to the inode file and adds the envelope to it.

Links the inode file to another inode file stored in the todo/inode directory so that the qmail-send module can process the file.

The qmail-queue module reads an e-mail message from two file descriptors. The first file descriptor contains the message text. The qmail-queue module does not change the message except that it prefixes Received at the front of the e-mail message. The line prefixed by Received includes the Process ID (PID) of the program, the message source, and a timestamp. The qmail-queue module then reads the second file descriptor, which contains envelope information with the sender and recipient addresses in binary format.

The qmail-queue module splits an e-mail message into three parts: the body of the message and two copies of envelope details. The qmail-queue module copies the message to a file in the queue/todo directory, copies the sender and recipient addresses in another file, and notifies to the qmail-send module.

The qmail-send module processes the queued messages. The qmail-queue module provides a return code to indicate if an e-mail message has been queued or not. The qmail-queue module returns zero if the e-mail message is successfully queued.

If an e-mail message is not successfully queued, the qmail-queue module provides a return code between 1-99. The return code between 11-40 indicates permanent mail delivery failure and the remaining return codes indicate temporary mail delivery failure.

Table 3-1 lists the various the qmail-queue module return codes:

Table 3-1: qmail-queue Return Codes

Return code

Description

11

Specifies a long address.

51

Specifies less memory space.

52

Specifies timeout.

53

Specifies that the qmail-queue module is unable to write an e-mail message due to full disk space.

54

Specifies that the qmail-send module is unable to read the message or envelope.

61

Specifies an error in the qmail home directory.

62

Specifies an error in the queue directory.

81

Specifies an internal bug.

91

Specifies an error in the envelope format.

If an e-mail message originates locally, the qmail-queue module calls the qmail-inject module to add the missing header lines to the message and clear the address fields. The qmail-inject module adds the following fields to the message header:

From: Specifies the name of the end user who sends the e-mail message.

Date: Specifies the current time in Greenwich Mean Time (GMT).

If an e-mail message comes from a remote end user, the qmail-smtpd module receives the message through SMTP and allows the qmail-queue module to queue the message. The qmail-queue module places the message in the queue/todo directory from where the qmail-send module takes the message and analyzes the address of the recipient to identify if the recipient is local or remote.

If the recipient address is local, the qmail-send module notifies the qmail-lspawn module to activate the qmail-local module to perform the local mail deliveries. The qmail-local module accepts an e-mail message and performs actions listed in the qmail file containing address information. Depending on the content of the qmail file, the local mail delivery may perform one of the following functions:

Store the message into a mailbox.

Provide a different address where the e-mail message can be delivered.

Run a qmail program to handle the e-mail message.

If the recipient address is remote, the qmail-send module notifies the qmail-rspawn module to activate the qmail-remote module to perform the remote mail deliveries. The qmail-remote module delivers the e-mail message to each remote address through SMTP.

For each local or remote mail delivery, the spawn module writes the status report to the qmail-send module. A mail delivery that fails temporarily is retried later. A mail delivery that fails permanently produces a bounce report, which is mailed back to the e-mail message sender. After each delivery succeeds or fails, the qmail-send module notifies the qmail-clean module to remove the message files from the queue.

Mail Delivery and Protocols

An MTA can use two methods to transfer an e-mail message to multiple recipients. These methods are single recipient (RCPT) and multi RCPT mail deliveries. qmail uses the single RCPT mail delivery method where you need to establish multiple SMTP connections to the recipients who belong to the same host. The multi RCPT mail delivery method requires a single SMTP connection, with a single copy of e-mail message being delivered to all the recipients. No patches are available for implementing the multi RCPT method.

qmail uses the SMTP and Post Office Protocol (POP) protocols to perform mail delivery. qmail uses SMTP to deliver e-mail message to other MTAs. qmail allows the end users to remotely access and retrieve the e-mail messages using POP. In addition, qmail supports Variable Envelope Return Path (VERP) to enable the automatic identification of recipients for mailing list bounces.

Using the SMTP

SMTP is used to send e-mail messages from a mail client to a mail server. Two mail servers that run on different platforms can communicate using the SMTP protocol. SMTP mail delivery offers following advantages over other e-mail protocols, such as POP and Internet Message Access Protocol (IMAP):

Provides a mail system that ensures no mail loss.

Provides unlimited mail queuing.

Checks virus in all inbound e-mail messages using anti-virus programs.

Provides spam filtering of all inbound e-mail messages using a detection algorithm. Spam is a junk e-mail message, which is sent to the subscribers of a mailing list. You can filter spam to avoid receiving junk e-mail messages.

To establish a connection using the SMTP protocol, the message sender need to provide the following command:

MAIL From: <e-mail-address>

In the above syntax, the <e-mail-address> argument specifies the address of the e-mail message sender.

The recipient sends the message, 250, to acknowledge the receipt of the command. The sender then sends the message body to the recipient.

Using the POP

POP is a client/server protocol that is used to manage the mailboxes of end users. Mail client programs, such as Eudora, Microsoft Exchange, and Microsoft Outlook, use the POP protocol to download e-mail messages from a POP mail server. If you are not connected to the Internet, the POP mail server receives the e-mail messages. As a result, the e-mail messages are transferred from the POP mail server to your computer.

Note 

Mail client programs allow the end users to retrieve their e-mail messages from the central mail server to local computer.

To connect an end user to the POP mail server, the mail client programs establish a Transmission Control Protocol (TCP) connection to the server. During connection, the POP mail server uses the username and password to verify if the end user is authenticated or not. If the end user is authenticated, the end user reaches the transaction state.

In the transaction state, the end user can view, download, or delete the e-mail messages from the POP mail server. The POP protocol performs its function even if there is no connection with the Internet or network containing the POP mail server.

When an end user receives an e-mail message, the message is processed and stored in the mail file of the end user located on the central mail server. An end user can access e-mail messages from the mail server in two ways:

Locally by logging on to the mail server.

Remotely by using a mail client program, such as Microsoft Outlook, Microsoft Exchange, and Eudora that helps the end user to retrieve e-mail messages from the central mail server to the local computer.

When an end user checks for any received e-mail messages, the e-mail program logs on to the POP mail server using the POP protocol. The POP mail server requires a password, which an end user can set permanently into the e-mail program. The POP protocol provides a network connection only for the time during, which you upload or download e-mail files.

The POP mail server of qmail is called qmail-pop3d and it contains three modules, which are:

qmail-popup: Obtains username and password.

checkpassword: Verifies the username and password.

qmail-pop3d: Specifies the POP server.

Using VERP

VERP is used for message bounce detection. Every e-mail message has a unique return path, which remains same until the message is either delivered to the recipient or bounced. If an email message is undelivered, VERP helps identify the e-mail address of the subscriber to whom the e-mail message was sent. The bounced message contains reason for the failure of message delivery and specifies if the problem is temporary or permanent.

VERP encodes the recipient address as a part of the return address. When a message is undelivered, MUA decodes the return address and obtains the address of the recipient. The mailing list manager for qmail called ezmlm uses VERP to automatically handle e-mail message bounces.

Note 

Mailing list managers are the systems that manage mailing list subscribers and control resending of messages to those subscribers.

For example, the mailing list manager sends a message to the e-mail address, <crisp@example.org> with a return address, mlist-return-crisp=example.org@domain.com attached to the e-mail message. If a non-delivery notice is generated because the e-mail message remains undelivered, MUA retrieves the address of the recipient from the message. MUA, then, identifies that the e-mail address to which the e-mail message was undelivered is crisp@example.org.

Multi RCPT and Single RCPT Mail Deliveries

Mail servers use SMTP to deliver e-mail messages to the recipients. SMTP allows a message to be sent to multiple recipients in a single connection using multiple RCPT commands. The RCPT command specifies the recipient who receives the e-mail message. There are three ways to send a message to multiple recipients by using SMTP connection. For example, to send a message to three recipients on the same domain, recp. example.com, the three ways are:

Establish a single SMTP connection with the host, recp, and send a copy of the message to the first end user. Similarly, send a copy of the message to the second end user, then to the third end user, and finally close the connection.

Start multiple processes, each of which establishes a SMTP connection with the recp host. Each process sends a copy of the message to each end user and closes the connection. This method is called as single RCPT mail delivery.

Establish a SMTP connection with the recp host, send a copy of the message addressed to all the recipients, and close the connection. This method is called as multi RCPT mail delivery.

If a message is large, the first method will take long time and more network bandwidth to send the message to the recipient. This method can use VERP because a separate copy of the message is sent to each recipient and each message sent to a recipient has a unique return path.

Single RCPT mail delivery uses multiple SMTP connections and sends multiple copies of the message. It sends the messages at a fast rate, but utilizes large network bandwidth. In single RCPT, qmail can use VERP because each recipient gets its own copy of message. qmail always uses the single RCPT mail delivery method to transfer e-mail messages.

Multi RCPT mail delivery establishes only a single connection to the host and sends only one copy of the message addressed to all the recipients. Multi RCPT mail delivery utilizes network bandwidth in an efficient way. You cannot use multi RCPT mail delivery if the recipients belong to different hosts.

File Formats in qmail

End users can direct incoming messages to mailboxes in two formats, mbox and maildir, by using .qmail files. A mailbox is a file or directory that contains messages delivered to a local address. The location and the formats of mailboxes differ based on the transfer, user, and delivery agents involved in delivering e-mail messages.

The mbox Format

The mbox format is used to store one or more e-mail messages in a single file. An e-mail message encoded in the mbox format starts with a line, which is prefixed with From and ends with a blank line. The syntax of the line starting with From is:

From envelope_sender date additional_information

In the above syntax:

envelope_sender: Specifies the address of the e-mail message sender.

date: Specifies the delivery date of the e-mail message. It contains only 24 characters in the asctime format. For example, the syntax of the asctime format is:

Mon Aug 28 10:24:09 2004

additional_information: Specifies additional information about the delivered message. It is an optional argument.

The message between the From line and the blank line is in the Request For Comments (RFC) 822 format. To convert an e-mail message to the mbox format, qmail creates a From line using the current date and the address of the message sender. If the address of the sender is empty, qmail uses MAILER-DAEMON as the message sender. qmail writes the message by starting each line with >From quoting. >From quoting ensures that the lines in the message are not the From lines. Finally, qmail adds a blank line to the message.

Note 

The RFC 822 format specifies the syntax for the text in an e-mail message.

The mbox format supports file-locking feature because it stores more than one message in a single file. The file-locking feature avoids message corruption due to more than two processes modifying the mailbox simultaneously. For example, file locking allows a mail delivery program to deliver a message at the same time when a mail reader is deleting an existing message. If more than two processes modify the same file simultaneously, qmail locks the file when the first process uses it. All the other processes have only read-only permissions to the opened file.

The maildir Format

The maildir format stores each e-mail message in a separate file. As a result, the maildir format does not require file locking to maintain message integrity and prevent simultaneous updates from different mail delivery agents. A directory in the maildir format contains three subdirectories: new, cur, and tmp on the same file system.

Each message in a maildir mailbox is contained in a different file in one of the subdirectories. The new subdirectory stores all unread messages, the cur subdirectory stores the messages that have been read, and the tmp subdirectory stores the messages that need to be delivered.

The mail delivery agent creates a file called /tmp/time.pid.hostname in the tmp subdirectory to store all the incoming e-mail messages. The time argument denotes the number of seconds since January 1, 1970 midnight.

Each file in the new subdirectory is a successfully delivered e-mail message. The modification time of the file is the delivery date of the message. The message is in RFC 822 format, starting with a Return-Path line and a Delivered-To line.

A difference exists between the files in the cur subdirectory and the files in the new subdirectory. The files in the cur subdirectory are not new e-mail messages instead these messages have been read by the mail reading program.

Note 

qmail-pop3d supports only the maildir format mailboxes.

Obtaining qmail

You can obtain qmail support through the Internet mailing list or hired consultants. Alternatively, several companies also provide qmail installation support and administrative services. You can obtain qmail documentation through man pages, list archives, qmail sites, and Frequently Asked Questions (FAQs).

Licensing and Purchasing qmail

qmail is copyrighted by the author, Dan Bernstein, who is granted a monopoly on the work related to qmail. The qmail author grants the right to distribute qmail source code available on the Web site, http://cr.yp.to/qmail/dist.html. You cannot distribute modified qmail source code or non-var-qmail binary distributions, which are available on the Web site, http://cr.yp.to/qmail/var-qmail.html.

You can obtain the qmail source code from qmail packages. The various types of qmail packages are: basic qmail, intermediate qmail, and enterprise qmail. The basic qmail package includes the following features:

Installation and configuration of qmail

Installation of the TcpServer server that allows you to limit the number of simultaneous connections to a qmail service. You can configure TcpServer to deny access to specific hosts.

Installation of the daemontools package to control and monitor qmail services.

Pop3 server, qmail-pop3d, to help you to access your local mailboxes.

The fastforward package that stores multiple aliases in a single file, /etc/aliases, which is compatible with sendmail alias database.

The dot-forward package that helps users to control the delivery of e-mail messages they receive.

The checkpasswd module to securely handle logins to the mailbox of a user.

The intermediate qmail package includes the following features:

Installation and configuration of qmail

Installation of TcpServer

Installation of Daemontools

Web-based interface, qmailadmin, for virtual domain users

Fast and efficient mailing list manager, ezmlm

Auto-respond service, autoresponder, for e-mail messages

Virtual domain accounts manager, vpopmail, to verify the passwords.

Webmail

The enterprise qmail package includes the following features:

Installation and configuration of qmail

Installation of TcpServer

Installation of Daemontools

Web-based interface, qmailadmin, for virtual domain users

Fast and efficient mailing list manager, ezmlm

Auto-respond service, autoresponder, for e-mail messages

Virtual domain accounts manager, vpopmail

Anti-spasm filter called SpamAssassin to check if the received e-mail message is a spam or not.

Anti-virus filter called ClamAV to scan e-mail messages for viruses.

SQL Server called MySQL database to store user mailbox information and virtual host configuration.

qmail Documentation

The documentation available for qmail includes: man pages, FAQs, official qmail site, unofficial qmail site, and list archives. When you install qmail, the man pages get stored in the /var/qmail/man directory. To view the man pages, you need to add this directory to the MANPATH environment variable.

Note 

A list archive refers to a repository for a list of e-mail messages.

The commands that are used to set the MANPATH variable using different shells are:

Bourne (/bin/sh) shell: MANPATH=$MANPATH: /var/qmail/man;export MANPATH

Bash and Korn shell: export MANPATH=$MANPATH: /var/qmail/man

C shell: setenv MANPATH=$MANPATH: /var/qmail/man

To display a man page, use the following command:

man name-of-qmail-man-page

Note 

The man pages are available in HTML format on the Web site, http://www.qmail.org/mail/index.html.

The qmail distribution contains a series of documents in the /var/qmail/doc directory. The qmail documents include:

FAQ: Contains common questions with their answers. The FAQs are available in two forms, which are:

Plain text version available in the /var/qmail/doc/FAQ directory.

Online HTML version available on the Web site, http://cr.yp.to/qmail/faq.html. This version of FAQ is complete and updated regularly.

INSTALL.*: Contains documentation related to qmail installation.

PIC.*: Contains the description of how qmail performs its various tasks.

In addition to these documents, other installation related documentation is available on the Web site, http://www.qmail/org/man/index.html.

The official qmail site, http://cr.yp.to/qmail.html, is the main source of information about qmail. This Web site contains information about the topics, which are:

Description of qmail

List of qmail features

qmail security guarantee

Online version of FAQ

List of Web sites that use qmail

Changes in recent qmail versions

Documentation for qmail configuration

Plans for the future

Related qmail packages

Alternatively, the unofficial Web site, http://www.qmail.org/ is the main resource for obtaining information about qmail. This Web site includes information about the following topics:

List of commercial support providers for qmail

Collection of handy tips

Information about virus detection and spam prevention

User contributed add-ons and documentation

The qmail mailing list maintained by Bernstein contains troubleshooting information about qmail. You can use the mailing list to find solution to the queries related to qmail.

Mailing Lists

A mailing list is a list of e-mail addresses that is stored in a single e-mail address and accessible through this single e-mail address. The mailing lists may be open, closed, or moderated. In open mailing lists, any end user can post queries to the mailing list. In closed mailing lists, only the members of the mailing list can post queries to the mailing list. In moderated mailing list, the list owner needs to approve all the posted queries.

When you post a query to a mailing list, you need to specify sufficient information so that the people can respond in detail. You can include the following information in a query:

Details of the command you performed and the copies of the startup scripts.

Describe the possible outcome you wanted to achieve.

Describe the actual results. It can include the clippings of the log file and copies of messages along with the headers.

To join a mailing list, you can send a request to a special subscription e-mail address. The mailing list uses different addresses to perform different functions. The ezmlm list manager manages the following mailing list residing on the list.cr.yp.to host:

<listname-subscribe@list.cr.yp.to>: Helps you to subscribe by sending a blank message.

<listname-unsubscribe@list.cr.yp.to>: Helps you to unsubscribe by sending a blank message.

<listname-help@list.cr.yp.to>: Returns a list of command addresses and information about the use of qmail.

<listname@list.cr.yp.to>: Represents the submission address. The messages that you send to the submission address reach all the members of the list.

In addition to these mailing lists, the mailing lists residing on the cr.yp.to host are:

<qmail@list.cr.yp.to>: Represents an open and unmoderated qmail mailing list.

<qmailannounce@list.cr.yp.to>: Represents the qmail announcement mailing list where new releases of qmail are specified.

<serialmail@list.cr.yp.to>: Represents an open and unmoderated qmail mailing list.

<ezmlm@list.cr.yp.to>: Is used for the discussion of the ezmlm mailing list manager.

Each ezmlm list contains a list name, which is an e-mail address. The address of the list specifies the address to which the e-mail message is to be sent. You can use the ezmlm-make command to create and manage ezmlm mailing list.

Commercial Support for qmail

You can obtain commercial support for qmail from various companies, which are:

Crynwr Software: Provides online support for qmail.

James Craig Burley, Software Craftsperson: Provides assessment, installation, training, support, and documentation for qmail.

Internet Infrastructure Group, LLC: Provides support for qmail installation. You can obtain the support from this company through e-mail messages, phone call, or online help.

Saffron Solutions: Provides qmail and other software support to customers in US and Canada.

Bettercom: Provides installation and administrative services for qmail in Germany and other European countries.

Network Design & Build: Installs and supports qmail systems in UK.

G-Tech Consulting: Provides services for qmail support.

DRS Internet: Provides qmail support and installation.

Quist Consulting: Provides support for qmail in Canada and USA over the Internet.

BlackMesh: Provides complete qmail services including consultation about qmail.

iBase Technologies: Provides qmail based corporate e-mail solutions for the Asian region. It offers support for anti-virus, consultancy, and administrative services.

To obtain the price quote, you need to send an e-mail message to hostmaster@shupp.org.

Chapter 4: Installing and Running qmail

qmail is an open source software that is available in the form of binary Red Hat Package Managers (RPMs) and tar files. To install qmail on the Linux system, you need to download the support packages, ucspi-tcp, and daemontools of qmail, in addition to, the binary RPMs and tar files of qmail. The installation of qmail is customizable to suit your requirements. After installing qmail, you use the qmailadmin tool to add and delete the users, aliases, and mailing lists in qmail.

This chapter explains the prerequisites for installing qmail and describes how to install qmail using tar files and binary RPMs. It also explains how to start and stop qmail program. It explains the installation of the qmailadmin tool and how to manage qmail using the qmailadmin tool.

Installing qmail

You can install qmail using tar files and RPMs. When you install qmail using tar file the make setup check command installs the binary RPM. A binary RPM is a built-in package that contains all the files related to the RPM.

Installation Prerequisites

You need to ensure that the minimum hardware and software requirements are met before installing qmail. Various hardware and software requirements for installing qmail are:

UNIX-based operating system

Minimum 10 MB of hard disk space

GNUZip utility to extract the archived files

C compiler

qmail tar files

ucspi-tcp support package

daemontools support package

Various optional qmail tar files, such as dot-forward, fastforward, and ezmlm

To install qmail, you need to download the tar file of qmail and its various support packages, such as ucspi-tcp and daemontools. You can download the tar files of qmail from the http://www.qmail.org/netqmail-1.05.tar.gz, ucspi-tcp from ftp://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz, and daemontools from ftp://cr.yp.to/daemontools/daemontools-0.76.tar.gz Web sites. The ucspi-tcp support package helps to create client-server connections in qmail. The daemontools support package is used to control and monitor qmail services.

Installing qmail from Tar Files

You need to log on as the root user to install qmail. Before installing qmail, you need to verify whether or not the C compiler is installed on your computer. To verify this, you need to enter the following command at the command prompt:

cc

If the C compiler is installed on the computer, the message, No input files specified, is displayed. Otherwise the message, Command not found, is displayed.

Alternatively, you can also use the following commands to determine whether or not the C compiler is installed on the computer:

/usr/bin/cc
/usr/bin/gcc
/usr/local/bin/cc
/usr/local/bin/gcc
/usr/ccs/bin/cc

The above commands display the same output as specified in the previous command to indicate whether the C compiler is installed or not. After verifying that the C compiler is installed on your computer, you need to unpack the tar files of qmail and ucspi-tcp in the /usr/local/src directory.

The command to create the directory is:

mkdir -p /usr/local/src

You need to unpack the tar files of daemontools in the /package directory. The command to create the directory is:

mkdir -p /package

In the above command, the -p option does not display error if the specified directory already exists.

The command to move the tar files of qmail and ucspi-tcp to the /usr/local/src directory for unpacking the tar files is:

mv netqmail-1.05.tar.gz ucspi-tcp-0.88.tar.gz /usr/local/src

The above command moves the files, netqmail-1.05.tar.gz of qmail and ucspi-tcp-0.88.tar.gz of ucspi-tcp from the current directory to the /usr/local/src directory.

The command to move the tar file of daemontools to the /package directory is:

mv daemontools-0.76.tar.gz /package

The above command moves the tar file, daemontools-0.76.tar.gz of daemontools to the /package directory.

After moving the tar files to the required directories, you need to unpack the tar file of qmail, netqmail-1.05.tar.gz. The code to unpack the tar file is:

gunzip netqmail-1.05.tar.gz
tar xpf netqmail-1.05.tar

In the above code, the gunzip command removes .gz extension from the name to obtain the netqmail-1.05.tar file of the netqmail-1.05.tar.gz file and the tar command extracts contents from the netqmail-1.05.tar file. The tar command also creates the directory, netqmail-1.05 with the same name as that of the file.

The netqmail-1.05 directory stores a script file, collate.sh file that contains the commands that display the messages stating whether or not qmail is successfully unpacked on the computer. Enter the following code to check whether or not qmail is successfully unpacked:

cd netqmail-1.05
./collate.sh

In the above code, the cd command changes the current directory to the netqmail-1.05 directory. The second command runs the script file collate.sh in which the dot character specifies that the collate.sh file is stored in the current directory.

Figure 4-1 shows the output of the ./collate.sh command:

Click To expand: This figure shows that the tar file of qmail has been successfully unpacked.
Figure 4-1: The Output of the ./collate.sh Command

After unpacking the tar file of qmail, you also need to unpack the ucspi-tcp-0.88.tar.gz file using the gunzip and tar commands. You also need to change the current directory to /package directory to unpack the daemontools-0.76.tar.gz file.

After unpacking the tar files of qmail, ucspi-tcp, and daemontools, the tar command creates the corresponding directories, /usr/local/src/netqmail-1.05, /usr/local/src/ucspi-tcp-0.88, and /package/admin/daemontools-0.76.

You need to create a home directory for qmail to store all the files required for installing qmail. The command to create the home directory for qmail is:

mkdir /var/qmail

If you want to store the files related to qmail under a directory other than the home directory, you need to create a symbolic link of the directory. The command to create a directory other than the home directory of qmail is:

mkdir /etc/qmail

You can create a symbolic link between the qmail home directory and the /etc/qmail directory, using the following command:

ln -s /etc/qmail /var/qmail/control

The above command creates a symbolic link between the /etc/qmail and /var/qmail/control directories. If you create any file in the /etc/qmail directory, the copy of the file is automatically created in the /var/qmail/control directory, which represents a symbolic link.

Creating Users and Groups

You need to create user and group accounts before building qmail. The INSTALL.ids file contains the commands for creating user and group accounts. The /etc/passwd and /etc/group files contain information about the user and group accounts, which are used to access qmail.

Enter the following code at the end of the /etc/group file to create group accounts in qmail:

qmail:*:2107:
nofiles:*:2108:

In the above code, qmail and nofiles indicate the names of the group accounts. The numbers, 2107and 2108 indicate the group-id. You need to ensure that these group-ids are not already assigned to any group or you can assign any other number, which is not already assigned to the group-ids.

You also need to create users accounts by adding user entries in the /etc/passwd file.

Listing 4-1 shows the commands to add user entries in the /etc/passwd file:

Listing 4-1: Adding User Entries in the /etc/passwd File

alias:*:7790:2108::/var/qmail/alias:/bin/true
qmaild:*:7791:2108::/var/qmail:/bin/true
qmaill:*:7792:2108::/var/qmail:/bin/true
qmailp:*:7793:2108::/var/qmail:/bin/true
qmailq:*:7794:2107::/var/qmail:/bin/true
qmailr:*:7795:2107::/var/qmail:/bin/true
qmails:*:7796:2107::/var/qmail:/bin/true

The above listing shows that the /etc/passwd file stores user information, which includes username, password, user-id, group-id, home directory, and shell.

Building qmail

After unpacking the required files for qmail, you need to create a symbolic link for them. The process of linking the files required for qmail is known as building qmail. You need to change from the current directory to the /usr/local/src/netqmail-1.05/netqmail-1.05 directory for building qmail.

You need to check whether the C compiler is installed on the computer, which is the prerequisite to install qmail. If the gcc compiler is installed on your computer instead of the cc compiler, and its directory is not stored in the PATH environment variable, you need to edit the configuration files of the C compiler. The configuration files, conf-cc and conf-ld of the C compiler are stored in the netqmail-1.05 directory. You need to edit the configuration files by replacing the cc command stored in it with the gcc command.

After verifying the C compiler, you need to run the following command at the command prompt to install and build all the qmail files in the /var/qmail directory:

make setup check

The above command installs all the unpacked tar files of qmail on your computer and creates their symbolic links.

Figure 4-2 shows the output of the make setup check command:

Click To expand: This figure shows that the make setup command creates the install and instcheck files in the /usr/local/src/netqmail-1.05/netqmail-1.05 directory.
Figure 4-2: The Output of the make setup check Command

After building qmail, you need to perform post installation configuration of qmail using the config command. You need to run the following command at the command prompt to do the post installation configuration of qmail, if Domain Name System (DNS) is not configured on the computer:

./config-fast qmail.solutions.com

In the above command, qmail indicates the hostname and solutions.com indicates the domain name of the computer.

Figure 4-3 shows the output of the ./config-fast qmail.solutions.com command:

Click To expand: This figure shows the message indicating that qmail is configured on the computer.
Figure 4-3: The Output of the ./config-fast qmail.solutions.com Command

After configuring qmail, you also need to install ucspi-tcp and daemontools on your computer. You need to change from the current directory to the ucspi-tcp directory to replace the cc command with the gcc command in the conf-cc and conf-ld configuration files.

The code to install ucspi-tcp is:

patch < /usr/local/src/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
make setup check

In the above code, the patch command installs patches for ucspi-tcp, and then the make setup check command installs the files required for installing the ucspi-tcp support package of qmail.

Figure 4-4 shows the output of the patch and make setup check commands:

Click To expand: This figure shows that the ucspi-tcp-0.88 is installed on the computer.
Figure 4-4: The Output of the patch and make setup check Commands

After installing ucspi-tcp-0.88, you need to install daemontools on your computer. You need to change the current directory to the /package/admin/daemontools-0.76 directory and make the same changes, replacing the cc command with the gcc command in the conf-cc and conf-ld configuration files. The code to install daemontools is:

cd src
patch < /usr/local/src/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
cd ..
./package/install

Figure 4-5 shows the output of the ./package/install command:

Click To expand: This figure shows that the C files present in the daemontools-0.76 directory are compiled using the compile command.
Figure 4-5: The Output of the ./package/install Command

Installing qmail from Binary RPM

Before installing qmail from binary RPM, you need to ensure that the C compiler is installed on your computer. Binary RPM is a command line package management utility that performs various tasks, such as querying, installing, uninstalling, verifying, and upgrading any software. You need to install the following binary RPMs from the http://www.untroubled.org Web site, which are the support packages of qmail:

/supervise-scripts/supervise-scripts-3.5-1.noarch.rpm

/rpms/daemontools/daemontools-0.70-3.src.rpm

/rpms/ucspi-tcp/ucspi-tcp-0.88-1.i386.rpm

/ucspi-unix/ucspi-unix-0.36-1.src.rpm

/qmail+patches/current/qmail-1.03+patches-19.src.rpm

The code to install all these support packages of qmail is:

rpm 'i ucspi-tcp-0.88-1.i386.rpm
rpm 'i daemontools-0.70-3.src.rpm
rpm 'i ucspi-unix-0.36-1.src.rpm
rpm 'i supervise-scripts-3.5-1.noarch.rpm

If the support packages of qmail are in the form of source RPM, you need to create binary RPM from the source RPM. The command to create the binary RPM from the source RPM of qmail is:

rpm 'rebuild qmail-1.03+patches-19.src.rpm

Note 

A source RPM contains many source files that are stored in the tar archive format.

After creating the binary RPM from the source RPM, you need to install the binary RPM on your computer. The command to install the binary RPM of qmail is:

rpm 'i /usr/src/redhat/RPMS/i386/qmail-1.03+patches-19.i386.rpm

The above command installs all the required files for qmail on the computer.

If another MTA is running on your computer and listening to the Simple Mail Transfer Protocol (SMTP) port, you need to disable the running MTA to avoid conflict with the new MTA, qmail. For example, if the sendmail MTA is running on your computer, the command to disable the sendmail MTA is:

/etc/rc.d/init.d/sendmail stop

The above command disables the sendmail MTA, which is running on your computer and releases the SMTP port, 25.

Note 

It is recommended to remove any other MTA, such as sendmail that is running on your computer. The command to remove the running MTA, sendmail is:

rpm 'e '-nodeps sendmail

Alternatively, you can also use the following command to stop the execution of sendmail MTA:

/sbin/init.d/sendmail stop

The above command stops the execution of the sendmail script file. You can also stop the execution of the sendmail MTA by killing the running process of sendmail, using its process-id. The ps command displays the process id of a running process. The command to display the process-id of sendmail is:

ps -ef | grep sendmail

The above command displays the process-id of the running process of sendmail.

Alternatively, you can use the following command to stop sendmail:

kill <process id of sendmail>

In the above code, you need to specify the process-id of sendmail, which is retrieved by the ps command in the kill command.

After disabling the running MTA, you need to add the SMTP service in qmail to enable multiple simultaneous connections, using the following command:

svc -add /var/qmail/service/smtpd

The above command starts the SMTP service and completes the installation process of qmail.

The configuration files of qmail are stored in different directories depending on the type of installation whether or not installed through tar files or binary RPMs.

Table 4-1 lists the directories created at time of installing qmail from binary RPMs and source RPMs:

Table 4-1: Different Directories for Binary RPMs and Tar Files

Files and Service

Binary RPM

Tar File

Login scripts

/etc/profile.d

None

System aliases

/etc/qmail/alias

/var/qmail/alias

Control files

/etc/qmail/control

/var/qmail/control

Post Office Protocol (POP) password checker

/bin/checkpassword

None

Cron job to rebuild qmail users database

/etc/cron.hourly/qmail

None

Files containing qmail UIDs and GIDs

/etc/qmail/owners

None

Qmail-users files

/etc/qmail/users

/var/qmail/users

Transmission Control TCP access control

/etc/tcpcontrol

/etc

Qmail programs

/usr/bin

/var/qmail/bin

Documentation files

/usr/share/doc/qmail-1.03+patches

/var/qmail/doc

Man pages

/usr/share/man

/var/qmail/man

Queue

/var/qmail/queue

/var/qmail/queue

Run scripts

/var/qmail/service

/var/qmail/supervise

Running qmail

You can run qmail after installing it on the computer. You need to create a script file to start or stop qmail. You can also use a built-in script file to run qmail. qmail starts various services, such as qmail-send, qmail-smtpd, and qmail-pop3d at the time of running qmail.

Starting qmail Using Script Files

You need to create the rc script file in the /var/qmail directory to start qmail using script files. The rc script file specifies the delivery instructions, which contain the location of the sent messages. You can execute the rc script file by assigning the execute permission to it.

Listing 4-2 shows the contents of the rc script file:

Listing 4-2: The rc Script File

#!/bin/sh
#Using stdout for logging
# Using control/defaultdelivery from qmail-local to #deliver messages by default
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "`cat /var/qmail/control/defaultdelivery`"

In the above listing, the qmail-start command requires the content of the defaultdelivery file as a parameter to initiate qmail.

The defaultdelivery file stores the location of a directory where the sent messages are stored. This file specifies the mailbox type of qmail.

Table 4-2 lists the various mailbox types:

Table 4-2: Various Mailbox Types

Name

Location

Mailbox format

Defaultdelivery

Mailbox

$HOME

Mbox

./Mailbox

Maildir

$HOME

Maildir

./Maildir

Username

/var/spool/mail

Mbox

INSTALL.vsm

To specify the mailbox type of qmail, you need to create the defaultdelivery file in the /var/qmail/control directory. The code to create the defaultdelivery file is:

echo ./Mailbox > /var/qmail/control/defaultdelivery

In the above code, the > symbol indicates the output redirection operator, which redirects ./Mailbox to the defaultdelivery file.

After specifying the mailbox type of qmail, you can create a script file to start and stop qmail while starting and shutting down the computer. The qmailctl script file is a startup/shutdown script file that starts and stops qmail at the time of starting and shutting down the computer. If you run the /var/qmail/rc script file manually, then qmail is partially started. The rc script is a boot script file, which does not stop qmail at the time of shutting down the computer. The qmailctl script file is stored in the /var/qmail/bin directory.

You can create the qmailctl script file using a Linux editor and store this file in the /var/qmail/bin directory.

You use the following command to make the qmailctl script file executable:

chmod 755 /var/qmail/bin/qmailctl

Listing 4-3 shows the contents of the qmailctl script file:

Listing 4-3: Displaying the Contents of the qmailctl Script File

#!/bin/sh
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
case "$1" in
start)
echo "Starting qmail"
if svok /service/qmail-send ; then
svc -u /service/qmail-send /service/qmail-send/log
else
echo "qmail-send supervise not running"
fi
if svok /service/qmail-smtpd ; then
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
else
echo "qmail-smtpd supervise not running"
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
if svok /service/qmail-pop3d ; then
svc -u /service/qmail-pop3d /service/qmail-pop3d/log
else
echo qmail-pop3d supervise not running
fi
;;
stop)
echo "Stopping qmail..."
echo "  qmail-smtpd"
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo "  qmail-send"
svc -d /service/qmail-send /service/qmail-send/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
echo "  qmail-pop3d"
svc -d /service/qmail-pop3d /service/qmail-pop3d/log
;;
stat)
svstat /service/qmail-send
svstat /service/qmail-send/log
svstat /service/qmail-smtpd
svstat /service/qmail-smtpd/log
qmail-qstat
svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/log
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /service/qmail-smtpd
echo "Pausing qmail-pop3d"
svc -p /service/qmail-pop3d
;;
cont)
echo "Continuing qmail-send"
svc -c /service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /service/qmail-smtpd
echo "Continuing qmail-pop3d"
svc -c /service/qmail-pop3d
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /service/qmail-send /service/qmail-send/log
echo "* Restarting qmail-smtpd."
svc -u /service/qmail-smtpd /service/qmail-smtpd/log
echo "* Restarting qmail-pop3d."
svc -t /service/qmail-pop3d /service/qmail-pop3d/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat <<HELP
stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0

In the above listing, the commands to start, stop, pause, restart, and qmail are specified.

You need to create a symbolic link of the qmailctl script file with the /usr/bin directory using the following command:

ln -s /var/qmail/bin/qmailctl /usr/bin

The qmail Services

After running qmail, you need to create the directories containing the qmail services and the log directories, which store the errors that occurred at the time of initiating the qmail services. You need to create the run script file in the /var/qmail/supervise/<service> directory and the same run script file in the /var/qmail/supervise/<service>/log directory to start the qmail services. The run script file contains the commands to start the qmail service, which is stored in the supervise directory. The run script file in the /var/qmail/supervise/<service>/log directory contains the multilog command, which stores the errors that occurred at the time of running a service in a file.

You need to create the supervise directory in the /var/qmail directory to store various directories, such as qmail-send and qmail-smtpd for qmail services.

The code to create the supervise directory for the qmail services is:

mkdir 'p /var/qmail/supervise/qmail-send/log
mkdir 'p /var/qmail/supervise/qmail-smtpd/log

After creating the supervise directory, you need to create the run script file in the /var/qmail/supervise/qmail-send directory using the Linux editor. Enter the following code in the run script file to run the qmail services:

#!/bin/sh
exec /var/qmail/rc

The above code shows that the run script file executes the rc script file.

You also need to create the run script file in the /var/qmail/supervise/qmail-send/log directory using the Linux editor. Enter the following code in the run script file to store the errors in a file:

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail

The above code shows that the run script file in the /var/qmail/supervise/qmail-send/log directory runs the setuidgid command.

After creating the run script file for the qmail-send service of qmail, you also need to create it for the qmail-smtpd service of qmail. You need to create the run script file in the /var/qmail/supervise/qmail-smtpd directory.

Listing 4-4 shows the contents of the run script file in the /var/qmail/supervise/qmail-smtpd directory:

Listing 4-4: Displaying the Contents of the run Script File

#!/bin/sh
QMAILDUID='id -u qmaild' --Retrieve the userid of the
--qmail daemon user.
NOFILESGID='id -g qmaild' --Retrieve the groupid of
--the qmail daemon user.
MAXSMTPD='cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me'
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1

In the above listing, the MAXSMTPD variable contains the number of simultaneous SMTP connections, and the softlimit command restricts the memory used by each connection to 2 MB. The run script file runs the tcpserver on the SMTP port and checks whether the remote host is able to access qmail services before starting the qmail-smtpd service.

To specify the number of simultaneous connections to qmail, you need to create the concurrencyincoming control file in the /var/qmail/control directory, as shown in the following code:

echo 20 > /var/qmail/control/concurrencyincoming

The above code creates the concurrencyincoming file and stores 20, which indicates 20 simultaneous connections in qmail are possible.

You need to create the run script file in the /var/qmail/supervise/qmail-smtpd/log directory using the Linux editor. Enter the following code in the run script file to store the errors that occur when you run the qmail-smtpd service:

#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd

The above code shows that the /var/log/qmail/smtpd directory stores the error information.

After creating all the run script files, you need to make them executable, as shown in code:

chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run

The above code assigns the execute permission to the run script files stored in the qmail-send, qmail-smtpd, and log directories.

After executing the run script files, you need to set up the log directories, as shown in code:

mkdir -p /var/log/qmail/smtpd
chown qmaill /var/log/qmail /var/log/qmail/smtpd

The above code creates the smtpd directory in the /var/log/qmail directory and changes the owner of the directory to the qmaill user. You need to create a symbolic link of the supervise directory with the /service directory, as shown in code:

ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service

The above code creates a symbolic link between the services, qmail-send and qmail-smtpd with the /service directory.

Note 

The /service directory is created automatically after installing the daemontools software.

Stopping qmail Service

You can use the qmailctl command to check whether or not all the qmail services are running. The stat parameter of the qmailctl command displays the message to indicate the status of qmail services. The command to check the status of qmail services is:

qmailctl stat

The above command displays the status of four services of qmail, qmail-send, qmail-send/log, qmail-smtpd, and qmail-smtpd\log.

Figure 4-6 shows the output of the qmailctl stat command:

Click To expand: This figure shows the various messages indicating that all qmail services are running.
Figure 4-6: The Output of the qmailctl stat Command

The command to stop the qmail services is:

qmailctl stop

The above command stops the qmail-smtpd and qmail-send services of qmail.

You can also test the installation of qmail by executing the inst_check script file. If the inst_check script file generates any error that are occurred at the time of installing qmail, you need to fix them by running the inst_check script file again. You need to reinstall qmail, if the errors are still not fixed after rerunning the inst_check script file.

The command to run the inst_check script file is:

sh inst_check

The above command displays the message indicating that the installation of qmail is successful.

Figure 4-7 shows the output of the sh inst_check command:

Click To expand: This figure shows the message, Congratulations, your LWQ installation looks good! indicating that qmail is successfully installed.
Figure 4-7: Output of the sh inst_check Command

Note 

You need to ensure that the qmaill user is the owner of the /var/log/qmail directory.

Using qmailadmin Tool to Manage qmail

qmailadmin is an open source administrative tool that provides Graphical User Interface (GUI) to manage qmail. To use the qmailadmin tool, you need to log on as the root user. You can add and delete the users, aliases, forward accounts, and mailing lists in qmail using the qmailadmin tool.

Installing qmailadmin

You need to install the qmailadmin tool to manage the e-mail account, forward accounts, aliases, and mailing lists. You must install the following support packages on your computer before installing the qmailadmin tool are:

qmail: Installs MTA for UNIX and its variants.

vpopmail: Creates virtual e-mail domains in qmail.

autorespond 2.0 or later: Creates automatic response to the received messages.

ezmlm: Creates mailing lists in qmail.

You need to download the tar files of vpopmail, autorespond, and ezmlm support packages and unpack these files. You need to configure and install these tar files using the configure and make install commands. After installing the vpopmail, autorespond, and ezmlm software, you need to download the tar file of the qmailadmin tool from the http://www.inter7.com/index.php?page=qmailadmin Web site.

To install the qmailadmin tool:

Untar the compressed file of the qmailadmin tool using the following command:

tar -zxvf qmailadmin-1.2.0.tar.gz

The above command extracts the files from the tar file of the qmailadmin tool and creates the directory, qmailadmin-1.2.0.

Change the current directory to the qmailadmin-1.2.0 directory and use the following command to configure the qmailadmin tool:

./configure

Figure 4-8 shows the output of the configure command:

Click To expand: This figure shows the directories that are configured for the qmailadmin tool.
Figure 4-8: Output of the configure Command

Note 

qmail must contain the vchkpw vpopmail user and group account for accessing the services of qmail. If qmail does not contain these user and group account, you need to create them, as shown in code:

groupadd -g 89 vchkpw
useradd -g vchkpw -u 89 vpopmail

You can change the default settings of the qmailadmin tool using the configuration options. The various configuration options that you can use with the configure command to change the default settings are:

--enable-cgibindir={dir}: Changes the default location, /var/www/cgi-bin of the cgi-bin directory. The cgi-bin directory contains the HyperText Markup Language (HTML) pages and the dir parameter, which specifies the new location of the cgi-bin directory.

--with-htmllibdir={dir}: Changes the default location, /usr/share/local/qmailadmin of the qmailadmin HTML library directory.

--enable-qmaildir={dir}: Changes the default location, /var/qmail where qmail is installed.

--enable-vpopuser={vpopuser}: Assigns the vchkpw vpopmail user to this option.

--enable-vpopgroup={vchkpw}: Assigns the vchkpw vpopmail group to this option.

--enable-autoresponder-bin={path}: Changes the default path, /usr/local/bin/autorespond of the autoresponder directory.

--enable-ezmlmdir={dir}: Changes the default location, /usr/local/bin/ezmlm of ezmlm.

--enable-maxpopusers={num}: Specifies the number of vpopmail users accessing qmail. The -1 value specifies the default value, which is unlimited, and the 0 value disables the default value.

--enable-maxaliases={num}: Specifies the maximum number of aliases.

--enable-maxforwards={num}: Specifies the maximum number of forward accounts.

--enable-maxautoresponders={num}: Specifies the maximum number of autoresponders.

--enable-maxmailinglists={num}: Specifies the maximum number of mailing lists.

Make the source code for the qmailadmin tool using the following command:

make

Figure 4-9 shows the output of the make command:

Click To expand: This figure shows that the source code of the qmailadmin tool is created in the /root/qmailadmin-1.2.0 directory.
Figure 4-9: Output of the make Command

Copy all the binary files of the qmailadmin tool to the default directory using the following command:

make install

Figure 4-10 shows the output of the make install command:

Click To expand: This figure shows the message indicating that the binary files of the qmailadmin tool are being copied to the /usr/local/share/qmailadmin directory.
Figure 4-10: Output of the make install Command

Type the URL, http://<domain_name>/cgi-bin/qmailadmin in the address bar of the Web browser to run the qmailadmin tool, as shown in Figure 4-11:

Click To expand: This figure shows the login screen of the qmailadmin tool that stores the default user account, postmaster in the User Account text box.
Figure 4-11: Running the qmailadmin Tool

To log on to the qmailadmin tool, you need to create a domain and specify the password for the postmaster user account, using the following command:

/home/vpopmail/bin/vadddomain "QmailSolutions.com" "admin"

In the above command, QmailSolutions.com is the name of a domain, and admin is the password of the postmaster user account.

Starting qmail Using qmailadmin

You need to enter the URL, http://qmail.solutions.com/cgi-bin/qmailadmin in the Web browser to start the qmailadmin tool.

Figure 4-12 shows the login screen of the qmailadmin tool:

Click To expand: This figure shows that the Domain Name text box contains QmailSolutions.com and the User Account text box contains postmaster.
Figure 4-12: Login Screen of the qmailadmin Tool

After clicking the Login button, the main menu screen of the qmailadmin tool appears, as shown in Figure 4-13:

Click To expand: This figure shows the main menu screen of the qmailadmin tool.
Figure 4-13: The main menu Screen

Various options in the main menu screen of the qmailadmin tool are:

Email Accounts: Add, delete, and modify e-mail accounts on a domain.

Forwards: Forward e-mail messages to the existing e-mail accounts or fake e-mail accounts.

Mail Robots: Create automatic reply for the received e-mail messages.

Mailing Lists: Store e-mail accounts of your acquaintances at one place.

Displaying E-mail Accounts

You need to select the Email Accounts options in the main menu screen of the qmailadmin tool to display a list of e-mail accounts. The Email Accounts screen appears, as shown in Figure 4-14:

Click To expand: This figure shows the list of e-mail accounts created in the domain.
Figure 4-14: The Email Accounts Screen

Adding Forward Accounts

You can transfer all the e-mail messages of one e-mail account to another e-mail account by creating a forward account. To create a forward account:

Select the New Forwards option from the main menu screen of the qmailadmin tool to display the Forward screen, as shown in Figure 4-15:

Click To expand: This figure shows the screen in which you specify the e-mail account where you need to forward its mail messages.
Figure 4-15: The Forward Screen of the Qmailadmin Tool

Enter mary in the Name text box to specify the e-mail account to forward its e-mail messages.

Enter james in the Destination text box to specify the name of the e-mail account in which all the e-mail messages are forwarded.

Click the Add button to add the forward account in qmail.

Figure 4-16 shows that the forward account has been added:

Click To expand: This figure shows the forward account, mary has been successfully added to the forwards list.
Figure 4-16: Adding the Forward Account

Adding Mail Robots

Mail Robot helps you to send a response automatically to the e-mail account from where it receives the e-mail messages. You need to add e-mail accounts to use the mail robot option of the qmailadmin tool. To add mail robot to an e-mail account:

Select the New Mail Robot option from the main menu screen of the qmailadmin tool to display the Add Mail Robot screen, as shown in Figure 4-17:

Click To expand: This figure shows the screen that contains various fields of Mail Robot.
Figure 4-17: The Add Mail Robot Screen of the qmailadmin Tool

The four fields of the Add Mail Robot screen are:

Mail Robot Names: Specifies the fake e-mail account that responds to the received e-mail messages.

Send copy to: Specifies the e-mail account that receives the auto-respond e-mail message.

Subject: Specifies the subject of the auto-respond message.

Message: Specifies the information that is sent in the auto-respond e-mail message.

Enter jack in the Mail Robot Name text box to specify the name of the mail robot.

Enter james@qmailsolutions.com in the Send copy to text box, to send the copy of the auto-respond message.

Enter Reply in the Subject text box to specify the subject for all the auto-respond messages and specify the auto-respond message in the Message text box.

Click Add to add the mail robot in the Mail Robots list and display the Mail Robots screen, as shown in Figure 4-18:

Click To expand: This figure shows that the jack@qmailsolutions.com mail robot is successfully added in the Mail Robots list.
Figure 4-18: The Mail Robots Screen

Creating Mailing List

You can store e-mail accounts of your acquaintances in the mailing list. You need to create a mailing list and add the e-mail accounts into it. To create the mailing list:

Select the Add Mailing List option from the main menu screen of the qmailadmin tool. The Add Mailing List screen appears, as shown in Figure 4-19:

Click To expand: This figure shows the various options that you can specify for creating a mailing list.
Figure 4-19: The Add Mailing List Screen

Enter smith in the Mailing List Name text box to specify the name of the mailing list. You can specify any name in the Mailing List Name text box.

Enter smith@qmailsolutions.com in the List owner email address text box to specify the e-mail account of the owner who wants to create a mailing list.

Click Add to add the mailing list in qmail, and display the Mailing Lists screen, as shown in Figure 4-20:

Click To expand: This figure shows that the mailing list for smith user account has been successfully added. You can add the e-mail accounts, which are known as subscriber in the mailing list.
Figure 4-20: The Mailing Lists Screen

Click the red dot under the Add Subscriber column to add the e-mail accounts in the smith mailing list. The Add Subscriber to mailing list screen appears, as shown in Figure 4-21:

Click To expand: This figure shows the Email Address text box in which you need to specify the e-mail account that you want to add in the smith mailing list.
Figure 4-21: The Add Subscriber to Mailing List Screen

Enter jack@qmailsolutions.com in the Email Address text box to add it in the smith mailing list.

Click Add to add the jack@qmailsolutions.com e-mail account in the smith mailing list and to display the List Subscriber screen, as shown in Figure 4-22:

Click To expand: This figure shows the message indicating that there is only one subscriber in the smith mailing list.
Figure 4-22: The List Subscriber Screen

Chapter 5: Migrating Existing Mails From Exchange Server

You need to convert the existing e-mail messages from the Exchange Server file format, such as .pst, to the qmail file format, such as mbox, for migrating from Exchange Server to qmail.

First, the existing e-mail messages of Exchange Server are stored in the local folders. Then the stored e-mail messages are converted into the qmail file format by using the conversion tools, such as Dbxconv. The converted e-mail messages are then imported into the Mail User Agents (MUAs) of qmail, such as Ximian Evolution, which allows you to send and receive e-mail messages. Ximian Evolution also provides additional features, such as calendaring service that allows you to schedule and manage various tasks, such as appointments.

This chapter explains how to convert Exchange Server file formats into the qmail file formats. It also explains how to configure and use the MUAs, Ximian and KMail in Linux.

Exporting Files Locally

The export of e-mail messages to the local folders helps create a backup of the e-mail messages. It also helps to convert the saved e-mail messages into other formats, such as mbox. The MUAs of Exchange Server, such as Microsoft Outlook and Outlook Express, store the e-mail messages in the .pst and .dbx formats. The stored e-mail messages are then converted into the file formats supported by qmail, such as mbox and maildir.

Exporting Files to .pst Format

You can export e-mail messages stored in Microsoft Outlook to the .pst format using the Import and Export Wizard. To export files to the .pst format:

Open Microsoft Outlook and select File -> Import and Export to export the e-mail messages. The Import and Export Wizard screen appears, as shown in Figure 5-1:

Click To expand: This figure shows a list of actions that you can perform using the Import and Export Wizard.
Figure 5-1: The Import and Export Wizard Screen

Select the Export to a file option from the Choose an action to perform list box to export the e-mail messages to a file.

Click Next to open the Export to a File screen, as shown in Figure 5-2:

Figure 5-2: The Export to a File Screen

Select the Personal Folder File (.pst) option from the Create a file of type list box to export the e-mail messages into the .pst format.

Click Next to open the Export Personal Folders screen, as shown in Figure 5-3:

Click To expand: This figure shows a screen that displays a tree view of the Mailbox folder. You can export these folders to different formats.
Figure 5-3: The Export Personal Folders Screen

Select the Inbox option from the Mailbox folder of the mail user, jerry, to export the e-mail messages stored in the inbox.

Click Next to specify the location of the exported files, as shown in Figure 5-4:

Click To expand: This figure shows a screen in which you can specify the location of the exported files.
Figure 5-4: Specifying the Location of the Exported Files

Enter the location where the exported files are to be stored in the Save exported file as text box.

Select the Allow duplicate items to be created option to create duplicate copies of the e-mail messages.

Click Finish to export the e-mail messages stored in Microsoft Outlook.

You can use the conversion tools to convert the stored e-mail messages into the format supported by qmail, such as mbox.

Exporting Files to .dbx Format

You can export the e-mail messages stored in Outlook Express to the .dbx format using the Export option from the File menu of the Outlook Express main windows. To export files to the .dbx format:

Select File -> Export -> Messages to open the Choose Profile dialog box.

Select a profile from the Profile Name drop down list box and click OK to open the Export Messages dialog box, as shown in Figure 5-5:

Click To expand: This figure shows the various options, such as All folders and Selected folders, on the Export Messages dialog box.
Figure 5-5: The Export Messages Dialog Box

Note 

A profile is a name given to a specific export process.

Select the All folders option from the Export Messages dialog box and click OK to export the e-mail messages to the default location of the mailbox folders.

Note 

You can view the default location of a mailbox folder from its Properties dialog box.

Converting Files from Microsoft Formats

The e-mail messages stored in the .dbx and .pst formats are converted into the mbox format supported by qmail by using the third party conversion tools, such as Dbxconv. The converted e-mail messages are then imported by the MUAs of Linux.

Converting .dbx File to mbox Format

You can convert a .dbx file into mbox file format by using the conversion tool, Dbxconv. To convert a .dbx file into mbox format:

Create a new folder, convert.

Export the e-mail messages in the convert folder and store them in the .dbx format.

Download the zip file of the Dbxconv tool in the convert folder. You can download the zip file from the Web site, http://people.freenet.de/ukrebs/dbxconv.html.

Unzip the dbxconv.zip file in the convert folder.

Open the Command prompt windows and open the convert directory.

Enter the following command at the command prompt:

dbxconv -mbx *.dbx

Figure 5-6 shows the output of the dbxconv command:

Click To expand: This figure shows the conversion of the Pfolder.dbx file into the mbox format.
Figure 5-6: Output of the dbxconv Command

Change the extension of the .mbx format files created by dbxconv to the .mbox format.

Converting .pst File to mbox Format

You can convert a .pst file into the mbox file format by using the conversion package, LibPST. To convert a .pst file to the mbox format in Linux:

Download the LibPST package, libpst_0.3.4.tgz to the folder, mail_convert. You can download the libpst_0.3.4.tgz package from the Web site, http://sourceforge.net/projects/ol2mbox.

Open the Terminal window and change the current directory to the mail_convert directory.

Unzip the libpst_0.3.4.tgz file by entering the following command at the command prompt:

gunzip libpst_0.3.4.tgz

This command creates the libpst_0.3.4.tar file.

Unpack the LibPST package contained in the libpst_0.3.4.tar file by entering the following command:

tar -xvf libpst_0.3.4.tar

Figure 5-7 shows the output of the tar command:

Click To expand: This figure shows the various files, such as libpst.c, stored in the LibPST package.
Figure 5-7: Output of the tar Command

Change the current directory to the libpst_0.3.4 directory and enter the following command at the command prompt:

make

Figure 5-8 shows the output of the make command:

Click To expand: This figure shows the output of the program contained in the libpst.c file stored in the LibPST package.
Figure 5-8: Output of the make Command

Enter the following command at the command prompt to convert the .pst format file, backup.pst, to the mbox format:

./readpst/root/backup.pst

Figure 5-9 shows the conversion of the .pst format file, backup.pst, to the mbox format:

Click To expand: This figure shows the conversion of e-mail messages stored in the backup.pst file to the mbox file format.
Figure 5-9: Conversion of backup.pst to the mbox Format

You can view the converted e-mail messages by typing the following command at the command prompt:

vi Inbox

You can also import the converted e-mail message files to an MUA by using the import feature of the MUA.

Converting mbox Files to maildir Format

The Exchange file formats are converted into the maildir format by first converting the Exchange file format, such as .pst, to the mbox format of qmail. This mbox format is then converted into the maildir format by using conversion tools, such as mb2md.pl.

To convert an mbox file into the maildir format:

Copy the mb2md.pl.gz file and the mbox file to the home directory of the mail user. You can download the Mb2md.pl.gz file from the Web site, http://batleth.sapienti-sat.org/projects/mb2md/

Open the Terminal window and open the home directory.

Unzip the mb2md-3.20.pl.gz file by entering the following command at the command prompt:

gunzip mb2md-3.20.pl.gz

Figure 5-10 shows the output of the gunzip command:

Click To expand: This figure shows the conversion of the mb2md-3.20.pl.gz file to the mb2md-3.20.pl file by the gunzip command.
Figure 5-10: Output of the gunzip Command

Enter the following command at the command prompt to convert the mbox file into maildir format:

./mb2md-3.20.pl -s Pfolder.mbox

Figure 5-11 shows how to convert the mbox file into maildir format:

Click To expand: This figure shows the conversion of the mbox file to the maildir format, which stores each e-mail message in a separate file.
Figure 5-11: Conversion from mbox to maildir

The maildir format files are stored in the maildir folder of the home directory. You can also specify the name of the folder in which the converted e-mail messages are stored. For example, the command to store the converted e-mail messages in a folder, target, is:

./mb2md-3.20.pl -s Pfolder.mbox Target

You can view the converted e-mail messages in a separate file using the vi editor.

Introducing Ximian Evolution

Ximian Evolution is a MUA of Linux that allows an end user to send, receive, and compose e-mail messages. Ximian Evolution is a mail client application that provides a graphical user interfaces (GUIs) interface for sending, receiving, and composing e-mail messages. The Calendar feature of Ximian Evolution helps manage schedules, such as the time of an appointment.

You can start Ximian Evolution by using the following methods:

Selecting Main Menu -> Internet -> Evolution Email.

Typing evolution at the command line.

You can use various command line options of Ximian Evolution, such as offline, to start Ximian Evolution in the offline mode. The command to start Ximian Evolution in the offline mode from the command line is:

evolution --offline

Figure 5-12 shows the Ximian Evolution Main windows:

Click To expand: This figure shows various GUI components, such as menu bar and shortcut bar, of the Ximian Evolution Main window.
Figure 5-12: The Ximian Evolution Main Window

The various GUI components of the Ximian Evolution Main window are:

Menu Bar: Allows you to access various features of Ximian Evolution through different menus, such as File, View, and Actions.

Toolbar: Allows you to access various features of Ximian Evolution through different icons, such as New and Reply.

Shortcut Bar: Provides various shortcuts for accessing the different features of Ximian Evolution. For example, the Calendar icon on the Shortcuts bar opens the Calendar pane that helps to manage the scheduled tasks.

Status Bar: Displays various messages and information pertaining to a task, such as the amount of task completed.

Search Tool: Allows you to search an e-mail message.

Using Ximian Evolution

The Evolution Setup Assistant wizard is initiated when you start Ximian Evolution for the first time. The Evolution Setup Assistant wizard helps to perform various tasks, such as assigning the IMAP server for reading e-mail messages. The Evolution Setup Assistant wizard also helps to assign the SMTP server for sending the e-mail messages using the Secure Socket Layer (SSL) connection.

To start Ximian Evolution:

Select Main Menu -> Internet -> Evolution Email to open the Welcome page of the Evolution Setup Assistant wizard.

Click Next to open the Identity page of the Evolution Setup Assistant wizard, as shown in Figure 5-13:

Click To expand: This figure shows the Required Information and Optional Information frames on the Identity page.
Figure 5-13: The Identity Page of the Evolution Setup Assistant Wizard

The various options on the Identity page are:

Required Information frame: Provides the Full name and Email address text boxes that help to specify the name and e-mail address of the user.

Optional Information: Provides the Reply-To and Organization text boxes. You can enter the name of your organization in the Organization text box and the default recipient of e-mail messages in the Reply-To text box. The Reply-To and Organization options are optional.

Enter your name and e-mail address in the Full Name and Email address text boxes and click Next to open the Receiving Mail page of the Evolution Setup Assistant wizard, as shown in Figure 5-14:

Click To expand: This figure shows the Server Type drop-down list box that helps to select the type of server, such as IMAP, for receiving the e-mail messages.
Figure 5-14: The Receiving Mail Page of the Evolution Setup Assistant Wizard

Select IMAP from the Server Type drop-down list box to display the various configuration settings of the IMAP server pertaining to a specified user.

Figure 5-15 shows the configuration settings pertaining to the user, mike:

Click To expand: This figure shows the Host text box, which is used for entering the IP address of the IMAP server.
Figure 5-15: IMAP Server Configuration Settings

Enter the IP address of the Internet Message Access Protocol (IMAP) server in the Host text box, select the type of authentication from the Authentication type drop-down list box, and click Next to display the settings for checking the new e-mail messages, as shown in Figure 5-16:

Click To expand: This figure shows various options, such as the Check for new messages in all folders check box.
Figure 5-16: Configuring Options for Checking New E-mail Messages

Click Next to open the Sending Mail page of the Evolution Setup Assistant wizard, as shown in the Figure 5-17:

Click To expand: This figure shows the Server Type drop-down list box that helps to select the type of server that is to be used to send the e-mail messages.
Figure 5-17: The Sending Mail Page

Select SMTP from the Server Type drop-down list box, enter the IP address of the SMTP server in the Host text box, and click Next to open the Account Management page, as shown in Figure 5-18:

Click To expand: This figure shows the Name text box that helps specify the name of the mail account that you are creating.
Figure 5-18: The Account Management Page

Enter the name of the account in the Name text box and click Next to open the Timezone page, as shown in Figure 5-19:

Click To expand: This figure shows the Selection drop-down list box that helps to select a time zone.
Figure 5-19: The Timezone Page

Select a time zone from the Selection drop-down list box and click Next to open the Done page.

Click Finish on the Done page to open the summary page of Ximian Evolution and configure Ximian Evolution. Different users can configure Ximian Evolution According to their requirements.

Configuring Ximian Evolution

You can configure Ximian Evolution by using the Evolution Settings dialog box. Configuring Ximian Evolution helps perform various tasks, such as creating identities and e-mail accounts, and configuring security.

You can open the Evolution Settings dialog box by selecting the Settings option from the Tools menu of the Ximian Evolution main window. The Evolution Settings dialog box contains various pages:

Mail Accounts: Helps add and update the information pertaining to e-mail accounts, such as name of the server that you want to connect, the password authentication mode, and the method of downloading e-mail messages.

Folder Settings: Helps add and update the various folders, such as Default, Offline, and Autocompletion, of Ximian Evolution.

Mail Preferences: Helps set various options for the display settings, notifications, and security of Ximian Evolution.

Composer Preferences: Helps insert various styles, such as the shortcut types, spell checking, smiley images, and signatures for the e-mail messages.

Calendar and Tasks: Helps change the various settings, such as Time, Work Week, Alerts, and Task List for the calendar.

Directory Servers: Helps set a shared directory server, such as Lightweight Directory Access Protocol (LDAP) server.

Font Preferences: Helps change the fonts used in the e-mail messages.

Summary Preferences: Perform various settings, such as Mail, News Feeds, Weather, and Schedule for Ximian Evolution.

The Mail Accounts Page

You can open the Mail Accounts page by selecting the Mail Accounts icon on the Evolution Settings dialog box.

Figure 5-20 shows the Mail Accounts page:

Click To expand: This figure shows a list of existing e-mail accounts and displays various options, such as Add, Edit, and Delete to work with e-mail accounts.
Figure 5-20: The Mail Accounts Page

Various options on the Mail Accounts page are:

Add: Creates a new e-mail account using the Evolution Account Assistant wizard.

Edit: Modifies an existing e-mail account using the Evolution Account Editor dialog box.

Delete: Removes an existing e-mail account.

Default: Sets an existing e-mail account as the default e-mail account.

Disable: Disables an e-mail account if you do not want to check the e-mail messages of the e-mail account.

The Folder Settings Page

You can open the Folder Settings page by selecting the Folder Settings icon on the Evolution Settings dialog box.

Figure 5-21 shows the Folder Settings page:

Click To expand: This figure shows various types of subfolders, such as Mail, Contacts, Calendar, and Tasks of the Default folder.
Figure 5-21: The Folder Settings Page

Various tabs on the Folder Settings page are:

Default: Helps select the default folders, such as the inbox folder that are used by Ximian Evolution.

Offline: Helps select the folders that are stored locally when the offline mode is selected.

Autocompletion: Helps select the folder that is used by Ximian Evolution for autocompletion of e-mail addresses that are entered while addressing an e-mail message.

The Mail Preferences Page

You can open the Mail Preferences page by selecting the Mail Preferences icon on the Evolution Settings dialog box.

Figure 5-22 shows the Mail Preferences page:

Click To expand: This figure shows a screen containing three tabs, General, HTML Mail, and Colors.
Figure 5-22: The Mail Preferences Page

Various options on the General tab are:

Message Display: Shows the e-mail message as read after the specified time and highlights the quotations in different color.

Deleting Mail: Removes all the e-mail messages from the trash folders while exiting Ximian Evolution and confirms before deleting a folder.

New Mail Notification: Notifies when a new e-mail message arrives.

The Compose Preferences Page

You can open the Compose Preferences page by selecting the Compose Preferences icon on the Evolution Settings dialog box.

Figure 5-23 shows the Compose Preferences page:

Click To expand: This figure shows a screen consisting of three tabs: General, Signatures, and Spell Checking.
Figure 5-23: The Compose Preferences Page

The options on the General tab of the Compose Preference page are:

Shortcut type: Specifies the keyboard shortcut schemes, such as Microsoft Windows, XEmacs, and Emacs.

Default Behavior: Specifies the forward and reply styles, and the smiley images that are inserted in the e-mail messages.

Alerts: Warns when an e-mail message is sent without the subject and when an e-mail message is sent to the Bcc recipient only.

You can add the same footer in each e-mail message by creating a signature for the e-mail account. You need to click the Signatures tab on the Composer Preference page to open the Signatures screen, as shown in Figure 5-24:

Click To expand: This figure shows a screen that lists the name of signatures stored in Ximian Evolution.
Figure 5-24: The Signatures Screen

Various options on the Signatures screen are:

Add: Creates a new signature in Ximian Evolution.

Add Script: Creates a new signature, which is the output of the specified script file.

Edit: Modifies the text of the existing signature.

Delete: Removes the existing signature from Ximian Evolution.

To add a new signature, you need to click the Add button on the Signatures screen. The Edit signature window opens, as shown in Figure 5-25:

Click To expand: This figure shows a screen in which you can specify the name of the signature in the Name text box and adds the text for the signature in the text area.
Figure 5-25: The Edit signature Windows

Using the Spell Checking tab on the Composer Preference page, you can configure the spell-checking feature for the e-mail messages.

Figure 5-26 shows the Spell Checking screen:

Click To expand: This figure shows a screen that contains the English (American) language as a spell checking language for which the dictionary is installed in Ximian Evolution.
Figure 5-26: The Spell Checking Screen

The Calendar and Tasks Page

You can open the Calendar and Tasks page by selecting the Calendar and Tasks icon on the Evolution Settings dialog box.

Figure 5-27 shows the Calendar and Tasks page:

Click To expand: This figure shows a screen containing two tabs, General and Display.
Figure 5-27: The Calendar and Tasks Page

Various options on the General tab of the Calendar and Tasks page are:

Time zone: Specifies the city where the e-mail user lives.

Time format: Specifies the time format, 12 hour (AM/PM), and 24 hour.

Week starts: Specifies the starting day of the week.

Work days: Specifies the working days in a week.

Day begins: Sets the time when the day starts in an organization.

Day ends: Sets the time when the day ends in an organization.

Alerts: Issues a warning when you delete an appointment and displays a reminder before a scheduled appointment.

Various options on the Display tab of the Calendar and Tasks page are:

Time divisions: Sets the increments from five minutes to 60 minutes, which are displayed in the daily views of the calendar.

Show appointment end times in week and month views: Displays the end time of the appointments in the week and month views of the calendar.

Compress weekends in month view: Displays the weekends in one box rather than in two separate boxes.

Show week numbers in date navigator: Displays the next week number in the calendar.

Tasks due today: Specifies the color for the tasks that are due today.

Overdue tasks: Specifies the color for the tasks that are overdue.

The Directory Servers Page

You can open the Directory Servers page by selecting the Directory Servers icon on the Evolution Settings dialog box.

Figure 5-28 shows the Directory Servers page:

Click To expand: This figure shows a screen containing the name of a LDAP server.
Figure 5-28: The Directory Servers Page

To add a new LDAP server:

Click the Add button on the Directory Servers page to open the LDAP Configuration Assistant wizard. Click the Next button to open the Server Information screen, as shown in Figure 5-29:

Figure 5-29: The Server Information Screen

Enter the name of a server in the Server name text box.

Select the Anonymously option from the log in method drop-down list box to set the anonymous access for the ldap server.

Click Next to open the Connecting to Server page, as shown in Figure 5-30:

Click To expand: This figure shows a screen in which you can specify the port on which the LDAP server is connected.
Figure 5-30: The Connecting to Server Page

Select 386 from the Port number drop-down list box.

Select Whenever Possible from the Use SSL/TLS drop-down list box. This option connects Ximian Evolution to the LDAP server through SSL/TLS, whenever required.

Click Next to open the Searching the Directory page, as shown in Figure 5-31:

Click To expand: This figure shows a screen that provides various options, such as Search base, which helps to specify the location from where the directory search begins.
Figure 5-31: The Searching the Directory Page

Click Next to open the Display Name page, as shown in Figure 5-32:

Click To expand: This figure shows a screen in which you can specify the name for the LDAP server that appears in folder list of Ximian Evolution.
Figure 5-32: The Display Name Page

Enter LDAP Server in the Display name text box to specify the display name for the LDAP server.

Click Next to open the Finished page.

Click Finish to add the new LDAP server.

Figure 5-33 shows an entry of the new LDAP server in the Directory Servers page:

Click To expand: This figure shows a screen indicating that the new LDAP Server has been successfully added in the Directory Servers page.
Figure 5-33: Displaying the Newly Added LDAP Server

The Font Preferences Page

You can open the Font Preferences page by selecting the Font Preferences icon on the Evolution Settings dialog box.

Figure 5-34 shows the Font Preferences page:

Click To expand: This figure shows a screen containing the options, such as Variable-width and Fixed-width to specify the on-screen fonts and the printed fonts.
Figure 5-34: The Font Preferences Page

The Summary Preferences Page

You can open the Summary Preferences page by selecting the Summary Preferences icon on the Evolution Settings dialog box.

Figure 5-35 shows the Summary Preferences page:

Figure 5-35: The Summary Preferences Page

Various tabs on the Summary Preference page are:

Mail: Displays the new e-mail messages stored in the folders of Ximian Evolution.

News Feeds: Displays the news headlines from the Web sites.

Weather: Displays the latest weather updates around the world.

Schedule: Shows the calendar and pending tasks.

Sending and Receiving E-mail Messages

Ximian Evolution helps users to perform various tasks, such as sending, composing, and receiving e-mail messages. You can read the e-mail messages from the inbox folder of Ximian Evolution. You can use various shortcuts while reading an e-mail message. For example, the spacebar key helps to view the next page and the backspace key helps to view the previous page of an e-mail message.

You can also sort an e-mail message list based on sender, subject, or date. You can sort an e-mail message list by clicking a column label in the message list area.

You can send an e-mail message by using the Compose a message window. To send an e-mail message:

Select File ->New ->Mail Message from the menu bar of the Ximian Evolution main window to open the Compose a message window, as shown in Figure 5-36:

Click To expand: This figure shows the various options of the Compose a Message window, such as the To and CC text boxes.
Figure 5-36: The Compose a Message Window

Enter the e-mail address of the recipient in the To text box and type the message in the message area.

Click the Send button on the Compose a Message window to send the e-mail message.

Note 

You can select Insert ->Attachment to open the Attach a file dialog box, which helps to send an attachment with the e-mail message.

Importing Files

Ximian Evolution also allows you to import files and settings from other mail client applications. You can import the files by using the Evolution Import Assistant wizard. To import mbox files:

Select File ->Import from the Ximian Evolution main window to open the Evolution Import Assistant wizard.

Click Next on the Evolution Import Assistant screen to open the Importer Type screen, as shown in Figure 5-37:

Click To expand: This figure shows the various options, such as Import a single file option that helps to import a file.
Figure 5-37: The Importer Type Screen of the Evolution Import Assistant Wizard

Select the Import a single file option and click Next to open the Select a File screen, as shown in Figure 5-38:

Click To expand: This figure shows the various options, such as Filename and File type that help to specify the name and type of the file.
Figure 5-38: The Select a File Screen

Enter the name of the file that you want to import in the Filename text box, select Mbox (mbox) from the File type drop down list box, and click Next to open the Import File screen.

Click Import on the Import File screen to open the Select folder dialog box, as shown in Figure 5-39:

Click To expand: This figure shows the tree view of the various folders in which you can import the mbox file.
Figure 5-39: The Select folder Dialog Box

Select a folder from the Select folder dialog box and click OK to import the mbox file to the selected folder.

Introducing KMail

KMail is a mail client application for the K Desktop Environment (KDE). KMail allows end users to access and use the messaging services provided by qmail. KMail provides a GUI for sending, receiving, and composing e-mail messages. KMail stores the e-mail messages in different folders, such as the sent-mail and inbox folders. KMail stores the e-mail messages in the maildir format, which stores each e-mail message in a separate file.

The various folders in which KMail stores the e-mail messages are:

Inbox folder: Stores the received e-mail messages.

Outbox folder: Stores a copy of the delivered e-mail messages.

Sent-mail folder: Stores a copy of each e-mail message that has been sent.

Trash: Stores all the deleted e-mail messages.

Drafts: Stores the e-mail messages that have been created but not sent.

You can also create new folders to store the e-mail messages. You can copy or move an e-mail message from one folder to another.

Using KMail

When the KMail mail client application is initiated, it creates a Mail folder in the home directory of the user. The Mail folder contains the various KMail folders, such as inbox and outbox.

To start KMail:

Select Main Menu ->Internet ->More Internet Applications ->KMail to open the Authorization Dialog dialog box, as shown in Figure 5-40:

This figure shows the various options, such as Username and Password, in the Authorization Dialog dialog box.
Figure 5-40: The Authorization Dialog Dialog Box

Enter the username and password and click OK to open the KMail main window, as shown in Figure 5-41:

Click To expand: This figure shows the various GUI components, such as the folder list and message list, of the KMail main window.
Figure 5-41: The KMail Main Window

The various GUI components of the KMail main window are:

Folders pane: Contains various folders, such as inbox and outbox that contain the e-mail messages. When you select a folder, the information about the e-mail messages stored in the folder is displayed in the Headers pane. The Folder pane also displays the total number of e-mail messages in a folder and the total number of unread e-mail messages.

Headers pane: Contains the header information pertaining to each e-mail message of the selected folder. This information includes the subject, date of arrival, and the address of the receiver pertaining to each e-mail message. When you select an e-mail message from the Message list, the content of the e-mail message are displayed in the Message pane.

Message pane: Displays the contents of the selected e-mail message.

Configuring KMail

You can configure KMail by using the Configure - KMail dialog box. Configuring KMail helps to perform various tasks, such as creating identities and e-mail accounts, and configuring security.

You can open the Configure - KMail dialog box by selecting the Configure KMail option from the Settings menu of the KMail main window. The Configure - KMail dialog box contains various pages:

Identities: Helps create new identities. An identity is a combination of name, e-mail address, and various settings, such as the folders that are to be used as sent-mail folder and the drafts folder.

Network: Helps configure the settings that determine how KMail sends or receives e-mail messages.

Appearance: Helps configure the layout of e-mail messages. You can configure the color and font of the text of the e-mail message on this page.

Composer: Helps configure the composer page of the KMail main window. You can select various options from this page, such as the External Editor option that helps to select the editor for the composer page.

Security: Helps configure the security of KMail. For example, you can choose the Pretty Good Privacy (PGP) or GnuPGP software for encrypting the e-mail messages.

Folders: Helps configure the various settings related to the folders. For example, the Empty trash folder option deletes all the messages from the trash folder when you close KMail.

Working with KMail

KMail helps the users to perform several operations, such as sending and receiving e-mail messages, maintaining address books, and importing e-mail messages from other mail clients. KMail provides various windows, such as the Composer window, which helps to create and send an e-mail message.

Reading E-mail Messages

You can read an e-mail message in KMail using its main window. The Folders pane of the KMail main window contains the inbox folder, which contains all the received e-mail messages. To read an e-mail message:

Select the inbox folder from the Folders pane to open a list of received e-mail messages in the Headers pane.

Select an e-mail message from the Headers pane. The content of the e-mail message appears in the Message pane, as shown in Figure 5-42:

Click To expand: This figure shows the Inbox folder of the user, John.
Figure 5-42: Reading E-mail Messages

Sending E-mail Messages

You can compose and send an e-mail message by using the Composer window of KMail. You can open the Composer window in two ways:

Selecting Message ->New Message from the menu bar.

Selecting the New Message icon on the KMail main window.

To send an e-mail message:

Select Message ->New Message from the menu bar to open the Composer window, as shown in Figure 5-43:

Click To expand: This figure shows the various options, such as the To and CC text boxes on the Composer window.
Figure 5-43: The Composer Window

The various options on the Composer window are:

Identity: Helps to select an identity, which is to be used for sending the e-mail message, from a drop-down list box.

To: Helps to specify the e-mail address of the recipient to whom you want to send an e-mail message.

CC: Helps to specify the e-mail addresses of the recipients to whom you want to send the carbon copy of an e-mail message.

Subject: Helps to specify the subject line of the e-mail message.

Message area: Specifies the text area for entering the content of the e-mail message.

Enter an e-mail address in the TO text box and type the message in the message area.

Note 

If you want to send the e-mail message to more than one recipient, enter their e-mail addresses in the CC text box.

Select Attach ->Attach File from the menu bar of the Composer window to open the Attach File dialog box, as shown in Figure 5-44:

Click To expand: This figure shows the Attach File dialog box, which helps locate the file that you want to send as an attachment with an e-mail message.
Figure 5-44: The Attach File Dialog Box

Select the attachment file and click OK. The attachment file with its name and other attributes, such as type and size, appears in the lower pane of the Composer window.

Select Settings ->Spellchecker to open the kmail dialog box, as shown in Figure 5-45:

Figure 5-45: The kmail Dialog Box

Select a dictionary from the Dictionary drop-down list box and click OK.

Select Tools ->Spelling to check the spellings of the typed message using the selected dictionary.

Select Message ->Send from the Composer - KMail window to send the e-mail message.

This sends the e-mail message along with its attachment to the recipients, the addresses of which are specified in the TO and CC text boxes. If you want to send the drafted e-mail message later, you can select Message ->Save in Drafts Folder to save the e-mail message in the Drafts folder.

Importing E-Mail Messages from Other E-Mail Clients

KMail allows you to import e-mail messages and files from other mail client applications, such as Outlook Express. You can use the KMail & KAddressBook Import Filters dialog box to import e-mail messages and address books. You can open the KMail & KAddressBook Import Filters dialog box by selecting Tools ->Import from the menu bar of the KMail main window.

Figure 5-46 shows the KMail & KAddressBook Import Filters dialog box:

Figure 5-46: The KMail & KAddressBook Import Filters Dialog Box

Chapter 6: Setting up Directory Services

Directory services provide information about network objects, such as files, end users, and e-mail addresses. You can access this information using Lightweight Directory Access Protocol (LDAP), which is a set of protocols that helps access the information stored in a directory.

The LDAP directory service is based on the client/server model, which consists of a server and a client. The LDAP server contains data about the network objects that form the LDAP back-end database. An LDAP client connects to the LDAP server to access data from the LDAP back end database. The OpenLDAP server is an implementation of LDAP that provides a stand-alone LDAP server, libraries to implement LDAP, and a stand-alone LDAP replication server.

This chapter describes how to install and configure the OpenLDAP server to access information from directory services. It also explains how to integrate directory services with qmail.

Installing and Configuring the OpenLDAP Server

You need to install various packages, such as kerberos authentication services, and database software and threads, before installing the OpenLDAP server on a Linux system. The database server required for the OpenLDAP server is Berkeley Database (BSD) and the threads required for the OpenLDAP server are Portable Operating System Interface (POSIX) pthreads.

Installing the OpenLDAP Server

You can download the following rpm packages to install the OpenLDAP server:

openldap

openldap-clients

openldap-devel

nss_ldap

openldap-servers

In addition you can install the OpenLDAP client by using all the above OpenLDAP packages, except the openldap-servers package.

Note 

You can download these rpm packages from http://rpm.pbone.net/index.php3?stat=3&limit=3&srodzaj=3&dl=40&search=openldap.

You need to verify, which OpenLDAP packages are already installed before installing the OpenLDAP server. To verify the already installed OpenLDAP packages:

Enter the rpm -qa openldap* command at the command line to verify, which openldap packages are already installed. The output of this command is:

# rpm -qa openldap*
openldap-2.0.27-11
openldap-clients-2.0.27-11

This output shows that the openldap-2.0.27-11 and openldap-clients-2.0.27-11 rpms are already installed.

Enter the rpm -qa nss* command at the command line to verify, which nss rpm is already installed. The output of this command is:

# rpm -qa nss*
nss_ldap-202-5

This output shows that the nss_ldap-202-5 rpm is already installed.

To install the other rpm packages, which are not installed:

Enter the rpm -ivh openldap-servers-2.0.27-11.i386.rpm command at the command line to install the openldap-servers package. The output of this command is:

# rpm -ivh openldap-servers-2.0.27-11.i386.rpm
warning: openldap-servers-2.0.27-11.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:openldap-servers ########################################### [100%]

This output shows that the OpenLDAP server has been installed.

Enter the rpm -ivh openldap-devel-2.0.27-11.i386.rpm command at the command line to install the openldap-devel package. The output of this command is:

# rpm -ivh openldap-devel-2.0.27-11.i386.rpm
warning: openldap-devel-2.0.27-11.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...########################################### [100%]
1:openldap-devel ########################################### [100%]

This output shows that the openldap-devel-2.0.27-11.i386.rpm is installed.

Note 

The openldap-devel package contains the libraries and header files required for compiling the applications that use LDAP.

Enter the rpm -qa openldap* command at the command line to verify, which openldap rpms are installed. The output of this command is:

# rpm -qa openldap*
openldap-2.0.27-11
openldap-clients-2.0.27-11
openldap-servers-2.0.27-11
openldap-devel-2.0.27-11

This output shows a list of all the installed openldap packages, and verifies the successful installation of OpenLDAP server.

Using LDIF Files

LDAP Data Interchange Format (LDIF) is a data type that represents a directory and directory entries in text format. LDIF exchanges data and enables the synchronization of data among LDAP servers by formatting the data into an LDIF file. You can use LDIF files to perform the following functions:

Adding bulk records to a directory.

Restoring a directory.

Archiving a directory.

Applying bulk edited records to a directory.

Note 

An LDIF entry is a collection of attributes with a unique distinguished name (dn). An attribute in an entry is followed by multiple values. For example, for an entry, you need to use the cn attribute for the common name of the LDAP server, the dc attribute for the domain name, and the mail attribute for the e-mail address.

Entries in an LDIF file are stored on different lines of a file. The various types of lines in an LDIF file are:

Directive: Starts with any character except a white space or hash.

Continuation: Follows the Directive line and starts with a space. If the characters do not end in one line, you need to write the characters on the continuation line, which forms a part of the previous line.

Blank: Contains no text and separates two entry sequences in the LDIF file.

Comment: Starts with the hash character.

Separator: Starts with the dash character.

LDIF directives define the entries in LDIF files. The various LDIF directives are:

add: Defines the name of the attribute to be added to an existing LDAP entry. The syntax of the add directive is:

add: attributename

In the above syntax, attributename allows you to define a value for an attribute that needs to be added as an LDIF entry. The value may be a string, a base64 string, or a file Uniform Resource Locator (URL), which is in the form, </file://path/to/file. The base64 encoding format transmits image data and special characters over the Internet.

changetype: Defines the operation to be performed on an entry. The syntax of the changetype directive is:

changetype: type

In the above syntax, the type attribute specifies the add, delete, or modify directive.

delete: Defines the name of the attribute to be deleted. Multiple directives might define the attribute to be deleted. If no directive is specified with the delete directive, all the attributes with the argument, attributename, are deleted. The syntax of the delete directive is:

delete: attributename

In the above syntax, the attributename parameter specifies the name of the attribute that needs to be deleted.

dn: Defines a domain name. If the dn directive is not the first entry in the LDIF file, a blank line should precede the dn directive. The syntax of the dn directive is:

dn: DN

replace: Defines the name of the attribute to be replaced by other attribute names provided by the end user. The syntax of the replace directive is:

replace: attributename

You can also edit the LDIF entry to modify existing directory entries using the LDIF format. The syntax of an LDIF entry is:

#comment

dn: <distinguished name>

<attrdesc>: <attrvalue>
<attrdesc>: <attrvalue>

In the above syntax the <attrdesc> parameter represents the description of an attribute, and the <attrvalue> parameter represents the value of an attribute.

To continue a line in a LDAP entry, you need to provide either a space or a tab character at the start of the next line. The following parameter shows an entry of an LDIF file:

dn: cn=Ron Floyd, dc=Kim Leuis

You can write this entry in one of the following two formats:

dn: cn=Ron Floyd, dc=Kim
Leuis

or

dn: cn=Ron Floyd, dc=Kim
Leuis

In the above syntax, lines that begin with either a space or a tab are interpreted as continuation of the previous line. In the first instance of Leuis, a line starts with a white space and in the next instance it starts with a tab.

If an attribute value contains non-printing characters or begins with a space, a semicolon, or a less than character, you should use a double colon and the base64 encoding of a value along with the <attrdesc> attribute.

Configuring the OpenLDAP Server

You need to configure the OpenLDAP server after you install it. To configure the OpenLDAP server, you need to:

Create the LDAP database directory.

Modify the /etc/openldap/slapd.conf file stored in the /etc/openldap directory.

Convert the /etc/passwd file to the LDIF format.

Import the LDIF file from the BSD database server to the LDAP server. The LDAP server stores the LDIF file in the LDAP database directory.

Creating the LDAP Database Directory

The LDAP database directory stores information about end users, such as user name and password, in a database. You can create an LDAP database directory, such as smartdevelopers.com, to store user information. For example, you can enter the following command at the command line to create the smartdevelopers.com LDAP database directory:

# mkdir /var/lib/ldap/smartdevelopers.com

You need to provide access rights to an end user to the smartdevelopers.com LDAP database directory after you create it. Enter the following command to provide access rights to the user, ldap, on the smartdevelopers.com database directory:

# chown ldap:ldap /var/lib/ldap/smartdevelopers.com

Note 

The ldap user is created by default during installation of the openldap rpm.

After creating the smartdevelopers.com database directory, the root user needs to specify an encrypted password, such that only the root user is authorized to create the LDAP database, and import and export data from the LDAP database. Enter the slappasswd command at the command line to create an encrypted password. The output of the slappasswd command is:

# slappasswd
New password:
Re-enter new password:
{SSHA}eJpC3+591YlOpphn3Ev3icNTCMdXQ8ZG

This output specifies the encrypted password of an LDAP user.

Structure of the /etc/openldap/slapd.conf File

The /etc/openldap/slapd.conf file contains specific information about the configuration of the OpenLDAP server. You can modify the /etc/openldap/slapd.conf file to configure the OpenLDAP server based on end user information, such as user name and password of an end user.

Listing 6-1 shows a sample /etc/openldap/slapd.conf file, which is generated automatically when you install LDAP:

Listing 6-1: Sample /etc/openldap/slapd.conf File

# $OpenLDAP: pkg/ldap/servers/slapd/slapd.conf,v 2.8.8.7 2001/09/27 20:00:31 kurt Exp $
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/redhat/autofs.schema
include /etc/openldap/schema/redhat/kerberosobject.schema
# Define global ACLs to disable default read access.
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral ldap://root.openldap.org
#pidfile //var/run/slapd.pid
#argsfile //var/run/slapd.args
# Create a replication log on /var/lib/ldap for use by slurped.
#replogfile /var/lib/ldap/master-slapd.replog
# Load dynamic backend modules:
# modulepath /usr/sbin/openldap
# moduleload back_ldap.la
# moduleload back_ldbm.la
# moduleload back_passwd.la
# moduleload back_shell.la
# The next three lines allow use of TLS for connections using a dummy test
# certificate, but you should generate a proper certificate by changing to
# /usr/share/ssl/certs, running "make slapd.pem", and fixing permissions on
# slapd.pem so that the ldap user or group can read it.
# TLSCertificateFile /usr/share/ssl/certs/slapd.pem
# TLSCertificateKeyFile /usr/share/ssl/certs/slapd.pem
# TLSCACertificateFile /usr/share/ssl/certs/ca-bundle.crt
# Sample Access Control
# Allow read access of root DSE
# Allow self write access
# Allow authenticated users read access
# Allow anonymous users to authenticate
# access to dn="" by * read
# access to *
# by self write
# by users read
# by anonymous auth
# if no access controls are present, the default is:
# Allow read by all
# rootdn can always write!
#####################################################
# Allocating ldbm database definitions
#####################################################
database ldbm
suffix "dc=my-domain,dc=com"
#suffix "o=My Organization Name,c=US"
rootdn "cn=Manager,dc=my-domain,dc=com"
#rootdn "cn=Manager,o=My Organization Name,c=US"
# Cleartext passwords,especially for the rootdn, should
# be avoided. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# rootpw secret
# rootpw {crypt}ijFYNcSNctBYg
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd/tools. Mode 700 recommended.
directory /var/lib/ldap
# Indices to maintain
index objectClass,uid,uidNumber,gidNumber,memberUid eq
index cn,mail,surname,givenname eq,subinitial
# Replicas to which we should propagate changes
#replica host=ldap-1.example.com:389 tls=yes
# bindmethod=sasl saslmech=GSSAPI
# authcId=host/ldap-master.example.com@EXAMPLE.COM

The above listing shows the sample /etc/openldap/slapd.conf file, which contains three directives, global config directive, back-end specific directive, and database-specific directive.

The three directives are defined in the /etc/openldap/slapd.conf file on the basis of the type of information, such as global, back-end specific, and database specific. The sequence in which you define the three directives in the /etc/openldap/slapd.conf file are: the global directive, the back-end specific directive, and the database directive.

You need to specify the global information of the OpenLDAP server, such as the structure of the LDAP directory, in the global config directive. Specify information related to a back-end type, such as the SQL back end used for querying databases, of the OpenLDAP server in the back-end directive. Specify the information related to a specific database instance, such as the type of database used for OpenLDAP, in the database directive of the /etc/openldap/slapd.conf file.

Listing 6-2 shows the format of the /etc/openldap/slapd.conf file:

Listing 6-2: Format of the /etc/openldap/slapd.conf File

# Defining global configuration directive
<global config directives>
# Defining backend directive
backend <typeA>
<backend-specific directives>
# Defining first database and config directives
database <typeA>
<database-specific directives>
# Defining second database and config directives
database <typeB>
<database-specific directives>
# Defining second "typeA" database and config directives
database <typeA>
<database-specific directives>
# Defining subsequent backend, database and config directives
...

In the above listing, the global config directive accepts arguments that are separated by white spaces and enclosed in double quotes.

The global config directive in the /etc/openldap/slapd.conf file specifies the LDAP directory structure, and includes various schema files, such as core.schema and cosine.schema. These schema files help to extend the functionality of the existing LDAP library functions. For example, the following parameters show an entry for the global directive in the /etc/openldap/slapd.conf file:

include /etc/openldap/schema/core.schema
include /etc/openldap/schema/core.schema.default
include /etc/openldap/schema/cosine.schema

The global directive also includes the .pid file and .args files. The .pid file contains the ID of a process, and the .args file contains the arguments that help to start the OpenLDAP server. The following code snippet shows how to include the .pid and .arg files in the global directive of the /etc/openldap/slapd.conf file:

pidfile /var/run/slapd.pid
argsfile /var/run/slapd.args

You can use the access controls in the global directives to specify the type of access, such as read and write, to the LDAP database stored in the OpenLDAP server. The syntax to specify the access control is:

access to <what> by <whom> <access>

The above syntax contains different parameters, such as what, whom, and access. The <what> parameter contains the name of the object or attribute, to which you want to grant the access. The <whom> parameter contains the name of an end user who can access the objects specified in the <what> parameter. The different values of the <whom> parameter are:

Specifies that all the end users can access the LDAP database.

Anonymous: Specifies that unauthorized end users can also access the LDAP database.

Users: Specifies that only authorized end users can access the LDAP database.

Self: Specifies that the end users connected with a target object can access the LDAP database.

The access parameter specifies the type of access that you grant to an end user. The different values of the access parameter are:

None: Specifies that an end user cannot access the LDAP database.

Auth: Specifies that an authorized end user can access a server.

Compare: Specifies that an end user can access and compare different network objects.

Search: Specifies that an end user can access the search filters in the LDAP database.

Read: Specifies that an end user can access the LDAP database to read its objects.

Write: Specifies that an end user can access the LDAP database to write its objects.

Listing 6-3 shows how to specify the access control in the global directive of the /etc/openldap/slapd.conf file:

Listing 6-3: Specifying the Access Control

# Sample Access Control
# Allow read access of root DSE
access to dn="" by * read
access to *
# Allow self write access
by self write
# Allow authenticated users read access
by users read
# Allow anonymous users to authenticate
by anonymous auth
# if no access controls are present, the default is:
# Allow read by all

In the above listing, end users are granted access to read the directory objects, and the administrator is granted the access to write the directory objects. As a result, only an administrator can write in the directory.

The backend directives define the type of back end that is used by LDAP. The syntax to define a back-end directive in the /etc/openldap/slapd.conf file is:

backend <type>

The value of the type parameter in the above syntax defines the type of back end. The various types of back end supported by LDAP are:

Berkeley DB transactional backend (bdb): Provides multi-user read/write access to the LDAP database.

Domain Name System (DNS) SRV (dnssrv) backend: Provides access to a DNS server.

Lightweight Database Management (ldbm) backend: Provides read/write access to an LDAP database.

Lightweight Directory Access Protocol (ldap) backend: Provides access to the LDAP database directory.

Meta directory (meat) backend: Provides access to the meta directory.

passwd backend: Provides read-only access to a passwd file.

Perl backend: Provides access to the Perl scripts.

Shell backend: Provides access to the shell scripts.

SQL programmable backend: Provides access to a directory database using SQL queries.

The database directive represents the beginning of a new database definition. You can apply the database directives to the databases in which you define the global and backend directives. The syntax to define a database directive in the /etc/openldap/slapd.conf file is:

database <type>

In the above syntax, the value of the <type> parameter represents the type of database that LDAP supports, such as bdb and sql.

Modifying the /etc/openldap/slapd.conf File

You need to edit the information, such as database name, username, or password of a database user, in the /etc/openldap/slapd.conf file to configure the OpenLDAP server.

Listing 6-4 shows the modified information in the /etc/openldap/slapd.conf file:

Listing 6-4: Modifying the /etc/openldap/slapd.conf File

###################################################### ldbm database definitions
#####################################################
database ldbm
suffix "dc=smartdevelopers,dc=com"
rootdn "cn=Manager,dc=smartdevelopers,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# rootpw secret
rootpw {SSHA}eJpC3+591YlOpphn3Ev3icNTCMdXQ8ZG
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd/tools. Mode 700 recommended.
directory /var/lib/ldap/smartdevelopers.com
# Indices to maintain
index objectClass,uid,uidNumber,gidNumber,memberUid eq
index cn,mail,surname,givenname
eq,subinitial
# Replicas to which we should propagate changes
#replica host=ldap-1.example.com:389 tls=yes
# bindmethod=sasl saslmech=GSSAPI
# authcId=host/ldap-master.example.com@EXAMPLE.COM

In the above listing, the ldbm parameter represents the name of the LDAP database, the suffix parameter specifies the name of the LDAP server, and the rootpw parameter specifies the encrypted password.

Converting the /etc/passwd File to LDIF Format

You need to convert the data in the /etc/passwd file to the LDIF format for importing data to the LDAP database directory. The LDIF format is used to create data files in the OpenLDAP server. You need to convert the LDAP user file and the root user file stored on the OpenLDAP server to the LDIF format before converting the data in the /etc/passwd file to the LDIF format. To convert the data in the /etc/passwd file to the LDIF format:

Create an LDAP user account, if there is no existing LDAP user account.

Convert the /etc/passwd file to the LDIF format.

To create an LDAP user account:

Enter the following command at the command line to create a new LDAP user, such as john:

# useradd -g users john

Enter the passwd command to set a new password for the LDAP user, john. The output of the passwd command is:

# passwd john
Changing password for user john.
New password:
BAD PASSWORD: it's WAY too short
Retype new password:
passwd: all authentication tokens updated successfully.

This output specifies the change in existing password.

To convert the /etc/passwd file to the LDIF format:

Enter the following command at the command line to extract the data from the /etc/passwd file and store the data in the /etc/openldap/passwd.ldapusers file:

# grep john /etc/passwd >> /etc/openldap/passwd.ldapusers

The above command transfers the LDAP user name from the passwd file in the root directory to the passwd file in the openldap directory.

Enter the following command at the command line to extract the content of the passwd file in the root directory to the /etc/opeldap/passwd.root file:

# grep root /etc/passwd > /etc/openldap/passwd.root

The above command transfers the root user name from the passwd file in the root directory to the passwd file in the openldap directory.

Enter the locate migrate_passwd command at the command line to locate and verify the location of the migrate_passwd.pl conversion script in the list of migrating scripts. The output of the locate migrate_passwd command is:

# locate migrate_passwd
/usr/share/openldap/migration/migrate_passwd.pl

This output specifies the location of the migrate_passwd file.

Note 

The migrate_passwd.pl conversion script helps in the conversion of data files to the LDIF format.

Enter the following command at the command line to convert the LDAP user file for the user, john, to the LDIF format with the help of the migrate_passwd.pl conversion script:

# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.ldapusers
/etc/openldap/ldapusers.ldif

Enter the following command at the command line to convert the root file to the LDIF format:

# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.root
/etc/openldap/root.ldif

Start the OpenLDAP server to load the contents of the /etc/openldap/slapd.conf file. Enter the service ldap start command at the command line to start the OpenLDAP server. The output of the service ldap start command is:

# service ldap start
Starting slapd: [ OK ]

The migrate_passwd.pl script allows you to create users for a default organizational unit, People, with padl as its default domain. You need to change the default domain, padl, to the domain name of the LDAP server. You need to edit each record of the LDIF files, /etc/openldap/ldapusers.ldif and /etc/openldap/root.ldif using the vi editor to change the string, padl, to smartdevelopers. The vi editor command to replace the string, padl, with the string, smartdevelopers, is:

%s/padl/smartdevelopers/g

The /etc/openldap/slapd.conf file assigns Manager as a cn to the root user. This information can be added to the root LDIF file by inserting the cn: Manager parameter under the Unique Identification (UID) line in the file.

After editing the user and root LDIF files, you need to create the smartdevelopers.com.ldif file using the vi editor. This helps to define the attributes for the smartdevelopers domain and the organizational unit, People.

Listing 6-5 shows the contents of the smartdevelopers.com.ldif file:

Listing 6-5: The smartdevelopers.com.ldif File

dn: dc=smartdevelopers,dc=com
dc: smartdevelopers
description: Root LDAP entry for smartdevelopers.com
objectClass: dcObject
objectClass: organizationalUnit
ou: rootobject
dn: ou=People,dc=smartdevelopers,dc=com
ou: People
description: All people in organization
objectClass: organizationalUnit

The above listing shows the domain name as smartdevelopers, and the organizational unit as People.

Importing LDIF Files to OpenLDAP Server

You need to import all the three LDIF files, smartdevelopers.com.ldif, root.ldif, and ldapusers.ldif, to the OpenLDAP database directory of the OpenLDAP server by using the ldapadd command.

To import LDIF files to the OpenLDAP server:

Enter the following command at the command line to import the smartdevelopers.com.ldif file of the OpenLDAP server to the OpenLDAP database:

# ldapadd -x -D "cn=Manager,dc=smartdevelopers,dc=com" -W -f /etc/openldap/smartdevelopers.com.ldif

The output of this command is:

Enter LDAP Password:
adding new entry "dc=smartdevelopers,dc=com"
adding new entry "ou=People,dc=smartdevelopers,dc=com"

Enter the following command at the command line to import the root.ldif file to the OpenLDAP server:

# ldapadd -x -D "cn=Manager,dc=smartdevelopers,dc=com" -W -f /etc/openldap/root.ldif

The output of this command is:

Enter LDAP Password:
adding new entry "uid=root,ou=People,dc=smartdevelopers,dc=com"
adding new entry "uid=operator,ou=People,dc=smartdevelopers,dc=com"

Enter the following command at the command line to import the ldapusers.ldif file to the LDAP database:

# ldapadd -x -D "cn=Manager,dc=smartdevelopers,dc=com" -W -f /etc/openldap/ldapusers.ldif

The output of this command is:

Enter LDAP Password:
adding new entry "uid=john,ou=People,dc=smartdevelopers,dc=com"

Integrating Directory Services with qmail

LDAP provides access to non-relational databases, which store information about a specific end user, such as usernames and passwords. Multiple end users and servers can use LDAP to access the information about an end user. You can use qmail modules and Mail User Agents (MUAs) to configure the qmail mail server to use LDAP to access this information.

Using qmail Modules

You can use LDAP with qmail in two different ways: through Pluggable Authentication Module (PAM) and with qmail-ldap patch set. PAM is a mechanism that supports the user-authentication methods on the UNIX or Linux operating system. A Linux user is authenticated through the usernames and passwords stored in the /etc/passwd file. This method of authentication needs all the authentication information to be stored in the /etc/passwd file on each computer. When you use the PAM mechanism, you can store and access the user names and passwords from a centralized location through LDAP.

qmail-ldap patch is a set of files that integrate qmail with LDAP because the qmail mail server does not support LDAP. When you install the qmail-ldap patch on the UNIX operating system, qmail uses LDAP to obtain the user information from the database directory.

The various components of qmail-ldap patch are:

qmail-send: Manages the e-mail messages placed in the outgoing queue. qmail-send can also reschedule all the e-mail messages for immediate delivery.

qmail-queue: Accepts e-mail messages from a client computer and stores the e-mail messages in a queue.

qmail-local: Delivers the e-mail messages to a local computer. It also manages the .qmail files.

qmail-remote: Sends an e-mail message to a remote host through Simple Mail Transfer Protocol (SMTP).

qmail-lspawn: Searches for an end user and invokes the qmail-local module to deliver the e-mail messages to a local computer.

qmail-rspawn: Invokes the qmail-remote module to deliver the e-mail messages to a remote computer.

qmail-popup: Reads the user name and password specified by an end user, from the network and invokes the auth_pop module to verify the user name and password. qmail-popup invokes auth_pop for authentication of user credentials.

qmail-qmqpd: Receives e-mail messages from a remote host through Quick Message Queuing Protocol (QMQP).

qmail-ldaplookup: Verifies whether or not the LDAP setup is correct. You can use the qmail-ldaplookup -u [uid] or qmail-ldaplookup -m [mail address] options to verify the LDAP setup.

auth_imap: Authenticates an end user by invoking qmail-popup for an Internet Message Access Protocol (IMAP) session.

auth_pop: Authenticates an end user by invoking qmail-popup for a POP3 session.

qmail-pop3d: Manages a POP3 session and is invoked from the qmail-popup module.

qmail-smtpd: Communicates from port 25/tcp and receives e-mail messages from a remote host through SMTP.

qmail-inject: Reads an e-mail message from a standard input. It also adds headers to e-mail messages and invokes qmail-queue to manage the delivery of the e-mail messages.

Instaling qmail-ldap Patch

The installation of qmail-ldap patch helps to integrate qmail mail server with LDAP. You can download the qmail-ldap patch from the Web site, http://www.nrg4u.com/. You need to install and configure the following packages on a computer before installing the qmail-ldap patch:

OpenLDAP 2.x or higher version

OpenSSL 0.9.4 or higher version

daemontools-0.76

ucspi-tcp-0.88

djbdns-1.05

Note 

You can install these packages from the Red Hat Linux E3 CD.

You need an LDAP server to install the qmail-ldap patch . The prerequisites for installing the qmail-ldap patch are:

A pre-configured DNS server, such as smartdevelopers.com

An existing LDAP server

LDAP user entries, such as root and john, in the LDAP server

LDAP domain entry, smartdevelopers.com, in the LDAP server

The DNS server must contain the entry of the hostname on which the LDAP server is configured and running. This helps to perform the name resolution.

To install the qmail-ldap patch, you need to apply the qmail-ldap patches to the existing qmail-1.03 directory and add users and groups to qmail. To apply the qmail-ldap patches to the existing qmail-1.03 directory:

Download the qmail-1.03.tar.gz file from the Web site, http://cr.yp.to/software/qmail-1.03.tar.gz, and store it in the /root directory.

Obtain the qmail-ldap patch, qmail-ldap-1.03-20031001.patch.gz, from the RedHat Linux-3 CD, and store it in the /root directory.

Unzip the qmail-1.03.tar.gz and qmail-ldap-1.03-20031001.patch.gz files by using the gunzip command.

Enter the following command at the command line to apply the qmail-ldap patches to the existing qmail-1.03 directory:

cd qmail-1.03 # patch -p1 < /root/qmail-ldap-1.03-20031001.patch

Enter the commands at the command line to add groups as shown in Listing 6-6:

Listing 6-6: Adding Groups

# groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias alias
# useradd -g nofiles -d /var/qmail qmaild
# useradd -g nofiles -d /var/qmail qmaill
# useradd -g nofiles -d /var/qmail qmailp
# groupadd qmail
# useradd -g qmail -d /var/qmail qmailq
# useradd -g qmail -d /var/qmail qmailr
# useradd -g qmail -d /var/qmail qmails

In the above listing, the groupadd command adds a new group and useradd adds a new user to the LDAP directory.

Note 

Ignore all the errors that might generate when you execute the groupadd and useradd commands.

Enter the following set of commands at the command line to create a system user that virtual mail users use to access a local computer:

# groupadd vmail
# useradd -g vmail -d /var/vmail -m -s /sbin/nologin vmail
# rm /var/vmail/.*

Enter the following command at the command line to compile and install the qmail-ldap patch:

# make setup check

Edit the following control files, to configure the qmail-ldap patch:

Enter the following parameter to set the Fully Qualified Domain Name (FQDN) as linuxser1.smartdevelopers.com in the me control file:

echo "linuxser1.smartdevelopers.com" > /var/qmail/control/me

Enter the domain name parameters to accept e-mail messages from the domains in the rcpthosts file, asshown in the following command:

echo "smartdevelopers.com" > rcpthosts
echo "linuxser1.smartdevelopers.com" >> rcpthosts

Enter the following parameter to set the FQDN of the LDAP server, in the ldapserver control file:

echo "linuxser1.smartdevlopers.com" > /var/qmail/control/ldapserver

Enter the following parameter to define the base dn, which stores the qmail-ldap user accounts, in the ldapbasedn control file:

echo "ou=My Organization,dc=smartdevelopers,dc=com" > /var/qmail/control/ldapbasedn

Enter the following parameters to authenticate the LDAP user information:

echo "cn=administrator, dc=smartdevelopers,dc=com" > ldaplogin

Enter the following parameter, to limit the LDAP search to a specific objectclass, in the ldapobjectclass control file:

echo "My Organization" > /var/qmail/control/ldapobjectclass

Enter the following parameter to define a Boolean value, which specifies whether to search for an ldap user account if that ldap user is not found in the LDAP directory, in the ldaplocaldelivery control file:

echo 0 > /var/qmail/control/ldaplocaldelivery

Enter the following parameter to define a Boolean value, which enables or disables clustering in LDAP, in the ldapcluster control file:

echo 0 > /var/qmail/control/ldapcluster

Enter the following parameter in the defaultquotasize control file to define the default size of quotas:

 echo 1000000 > /var/qmail/control/defaultquotasize

Enter the following parameter in the defaultquotacount control file to limit the number of messages stored in a quota:

echo 1000 > /var/qmail/control/defaultquotacount

Enter the following parameter in the quotawarning control file to display a message to the user accounts that are approaching quota levels:

echo "Your quota limit is approaching!" > /var/qmail/control/quotawarning

Enter the following parameter in the ldapmessagestore control file to create the default home directory:

echo /var/vmail > /var/qmail/control/ldapmessagestore

Enter the following parameter in the ldaptimeout control file to limit the amount of time that an LDAP server waits before shutting down:

echo 30 > /var/qmail/control/ldaptimeout

Enter the following parameter to define the e-mail address of the sender that can relay through the server:

echo "smith@smartdevelopers.com" > relaymailfrom

Enter the following parameter in the rbllist control file to define a set of rules for accepting or rejecting the delivered e-mail messages:

touch /var/qmail/control/rbllist

Enter the following parameter in the outgoingip control file to define the Internet Protocol (IP) address that the qmail-remote file binds to:

echo 0.0.0.0 > /var/qmail/control/outgoingip

When you install and configure the qmail-ldap patches, qmail uses LDAP to search the information of a user account, such as the username, password, and group ID, in the LDAP database directory. qmail-ldap patches also support virtual mail users and routing mails to access the information of a user account across multiple servers.

After installing and configuring the qmail-ldap patch, you need to add the qmail.schema file to the slapd.conf file. Edit the /etc/openldap/slapd.conf file to add the following parameters:

include /etc/ldap/schema/qmail.schema

This parameter includes the qmail.schema schema file in the schema directory of the qmail-ldap patch.

Note 

You need to restart the slapd service to save the changes to the /etc/openldap/slapd.conf file.

After loading the schema you need to perform host configuration tasks to integrate LDAP with qmail. To perform the host configuration tasks:

Add the following parameter to the /etc/passwd file:

vmail:*:11184:2110::/var/qmail/maildirs/:/bin/true

This parameter creates an entry for a virtual mail user in the /etc/passwd file.

Add the following parameter in the /etc/group file:

vmail::2110

This parameter helps specify the ID of a virtual mail user.

Enter the following command at the command line to create a new maildir directory:

 # mkdir /var/qmail/maildir

Enter the following command at the command line to provide access rights to virtual mail users:

# chown -R vmail:vmail /var/qmail/maildir

Enter the following command at the command line to change the root directory to the /var/qmail/control directory:

# cd /var/qmail/control

Create the following control files, with specified parameters, at the /var/qmail/control location, to configure the host:

Create the defaultdelivery control file using the vi editorand enter the following parameter to specify the default delivery mode of qmail:

./Maildir/

Create the ldapmessagestore control file and enter the following parameter to specify the location where the LDAP server stores the e-mail messages:

/var/qmail/maildir

Create the ldapgid control file and enter the following group ID parameter to specify the group ID of an LDAP user:

21010

Create the ldapuid control file and enter the following user ID parameter to specify the user ID of an LDAP user:

1145

Create an LDIF file, my.ldif, and enter the following parameter to modify the first block of the LDIF file, such that the block matches the directory base defined in the /etc/openldap/slapd.conf file:

suffix "dc=smartdevelopers,dc=com"

Note 

The my.ldif file stores the configuration information, such as the domain name pertaining to a host.

Enter the following command at the command line, to load the my.ldif file into the LDAP database directory:

ldapadd -acrv -h linuxser1.smartdevelopers.com -D "cn= My
organization,dc=smartdevelopers,dc=com" -w managers_password -f my.ldif

Configuring MUAs to Access the Directory Services

MUA is a program that helps an end user to read, compose, and send e-mail messages to other end users on a network. LDAP supports various MUAs, such as OpenLDAP client, Mozilla mail, and Microsoft Outlook.

You need to configure these MUAs to access the OpenLDAP directory server. All the MUAs need similar configuration to access the OpenLDAP directory server.

Configuring The OpenLDAP Client MUA and OpenLDAP Client

You need to modify the properties of the /etc/openldap/ldap.conf file to configure the OpenLDAP client MUA. The properties that you need to modify to configure the OpenLDAP client are search base and server name. For example, to configure the OpenLDAP client to access an OpenLDAP server, such as smartdevelopers.com, you need to modify the ldap.conf file, as shown in the following code:

LDAP search base: dc=smartdevelopers,dc=com
LDAP server: ldap.smartdevelopers.com

In the above code, ldap is the server name and smartdevelopers.com is the domain name.

To configure the OpenLDAP client:

Open the /etc/openldap/ldap.conf file in the vi editor.

Edit the following parameters in the /etc/openldap/ldap.conf file, to configure the OpenLDAP client:

server linuxser1.smartdevelopers.com
base dc=smartdevelopers,dc=com

Save and exit the /etc/openldap/ldap.conf file.

Note 

The hostname entry, linuxser1.smartdevelopers.com, must exist in the network DNS server.

Configuring The Mozilla Mail MUA

You can add a new profile of the directory server, such as the OpenLDAP server, to the Mozilla mail using the address book application of the Mozilla mail. To configure the Mozilla mail address book to access the database directory services:

Open the Mozilla Web browser.

Select Windows -> Address book to open the Address Book window, as shown in Figure 6-1:

Click To expand: This figure shows different address books that an end user creates to store e-mail addresses.
Figure 6-1: The Address Book Window

Select File -> New -> LDAP directory to open the Directory Server Properties dialog box.

Specify the properties in the Directory Server Properties dialog box, as shown in Figure 6-2:

Click To expand: This figure shows the general properties of a directory server that are applied to the Mozilla mail. These properties help to access the OpenLDAP server.
Figure 6-2: The Directory Server Properties Dialog Box

Click OK to apply the properties to the Address book of the Mozilla mail explorer.

You can search for a name or string from the list of LDAP address books, after adding the LDAP directory to the list of e-mail addresses.

Figure 6-3 shows the Address Book window of the Mozilla mail:

Click To expand: This figure shows the e-mail addresses stored in the Personal address book.
Figure 6-3: The Address Book Window with E-mail Addresses

You need to add a list of e-mail addresses in the address book after configuring the Mozilla mail address book such that you can store the e-mail addresses in LDAP directory. To add a new e-mail address:

Open the Mozilla mail address book.

Select File -> New -> New Address Book Card, to open the New Card dialog box.

Enter the e-mail address and other details, such as name, in the New Card dialog box, as shown in Figure 6-4:

Click To expand: This figure shows the contact details of the end user, John.
Figure 6-4: The New Card for the User, John, Dialog Box

Click OK to save the entry for the contact details of the end user, John.

To search for an e-mail address in the address book of the Mozilla mail:

Open the Mozilla mail window.

Open the Address Book window of the Mozilla mail.

Select Tools -> Search Addresses to open the Advanced Address Book Search window, as shown in Figure 6-5:

Click To expand: This figure shows different options to search for an e-mail address stored in an address book.
Figure 6-5: The Advanced Address Book Search Window

Select the name of the address book from the Search in drop-down list box.

Specify the criteria to search the e-mail address in the Search in drop-down list box, on the Match any of the following pane.

Click Search to search for the e-mail address, as shown in Figure 6-6:

Click To expand: This figure shows the e-mail address of an end user, John Dew, displayed after searching an e-mail address on the basis of the specified criteria.
Figure 6-6: Displaying the Search Results

Configuring The Microsoft Outlook MUA

You can also add the directory server profile to Microsoft Outlook, such that you can access the database directory services. To configure Microsoft Outlook to add the directory server profile:

Select Start -> Programs -> Microsoft Outlook to open the Microsoft Outlook window, as shown in Figure 6-7:

Click To expand: This figure shows the Microsoft Outlook Express window
Figure 6-7: The Microsoft Outlook Windows

Select Tools -> Accounts to open the Internet Accounts dialog box, as shown in Figure 6-8:

Click To expand: This figure shows the Mail pane in the Internet Accounts dialog box, with various options to add new mail accounts.
Figure 6-8: The Internet Accounts Dialog Box

Click the Add button and select the Directory services option to open the Internet Directory Server Name screen of the Internet Connection wizard, as shown in Figure 6-9:

Click To expand: This figure shows the Internet directory (LDAP) server text box, where you need to specify the LDAP server name.
Figure 6-9: The Internet Directory Server Name Screen

Specify the ldap.smartdevelopers.com parameter in the Internet directory (LDAP) server text box of the Internet Directory Server Name screen.

Click Next on the Internet Directory Server Name screen to open the Check E-mail Addresses screen of the Internet Connection wizard, as shown in Figure 6-10:

Click To expand: This figure shows the options to check e-mail addresses using the directory services. You need to select the Yes option.
Figure 6-10: The Check E-mail Addresses Screen

Click Next -> Finish to close the Internet Connection wizard.

Open the Internet Accounts dialog box, which displays the LDAP server account added in the Accounts list box, as shown in Figure 6-11:

Click To expand: This figure shows the LDAP server account in the Internet Accounts dialog box.
Figure 6-11: The LDAP Server Account Added in the List of Mail Accounts

Select the linuxser1.smartdevelopers.com account and click Properties to open the linuxser1.smartdevelopers.com Properties dialog box.

Click the Advanced tab of the linuxser1.smartdevelopers.com Properties dialog box to display the advanced properties of the LDAP server, as shown in Figure 6-12:

Click To expand: This figure shows different options, such as Server Port Number, Search timeout, and Search base that help to configure Microsoft Outlook.
Figure 6-12: The Advanced Tab of the linuxser1.smartdevelopers.com Properties Dialog Box

Enter the dc=smartdevelopers, and dc=com parameters in the Search base text box on the Advanced tab of the linuxser1.smartdevelopers.com Properties dialog box, to specify the name of the OpenLDAP server.

Click Apply -> OK to apply the properties and close the linuxser1.smartdevelopers.com Properties dialog box and configure the Microsoft Outlook client.

Chapter 7: Setting up Authentication and Authorization

Authentication process confirms the identity of an end user or an entity before allowing access to network resources, such as shared printers and files. There are various protocols, such as New Technology Local Area Network (NT LAN) Manager (NTLM), Extended Simple Mail Transfer Protocol (ESMTP), and Kerberos that are used for authentication in Microsoft Exchange Server. These protocols help create an authentication scheme, which is a mechanism to authenticate end users accessing the network resources. In qmail, you can use Pluggable Authentication Module (PAM), which is a collection of modules defined to control the authentication process, to authorize an end user to access a qmail mail server.

This chapter describes various authentication schemes used in Exchange Server. It also explains how to use the PAM modules to authorize end users to access the Lightweight Directory Application Protocol (LDAP) server.

Authentication Schemes in Exchange Server

Authentication schemes in Exchange Server help you to authenticate different end users to access Exchange Server. The various authentication schemes that authorize an end user to access the Exchange server are using the NTLM protocol, the ESMTP protocol, and the Kerberos modules.

NTLM

NTLM is a security protocol of Windows NT that uses the challenge/response mechanism to authenticate end users in Exchange Server. In the challenge/response mechanism, a client computer sends a request for a task to a server computer, which sends back a response message to the client computer.

The three different types of messages that are used in the challenge/response mechanism of the NTLM protocol are:

Type1: Represents the negotiation message.

Type2: Represents the request message.

Type3: Represents the response or authentication message.

Note 

The client computer in the challenge/response mechanism does not need a password to access the server computer.

To authenticate an e-mail message using the NTML protocol:

A client computer sends a Type1 message, as a request, to a server computer.

The server computer sends a Type2 message, as a response to the Type1 message, to the client computer.

The client computer sends a Type3 message, as a confirmation, in response to the Type2 message received from the server computer.

ESMTP Authentication

ESMTP is an extension of the functionality of SMTP, and is used to authenticate end users in Exchange Server. ESMTP authentication can authorize the e-mail messages that contain graphics, audio, or video files. SMTP cannot verify these types of e-mail messages. Exchange Server supports various ESMTP commands, such as Extended turn (ETRN), to authenticate an end user. The ETRN command also helps the SMTP server to send the e-mail messages to the specific destination. ESMTP contains various add-ons, such as AUTH=LOGIN, STARTTLS, and TLS that support authenticated and encrypted connections between Exchange Server and other SMTP servers. Various other add-ons of ESMTP that help in sending and receiving the e-mail messages are:

Chunking: Sends and receives e-mail messages in binary chunks. The binary chunk is the compressed form of an e-mail message that needs less memory space of a mail server. Sending and receiving e-mail messages in binary form increases the performance of the mail server if the files attached to the e-mail message are of large size.

Pipelining: Issues a new command without waiting for an acknowledgement of the delivered e-mail message from other commands that are executed.

Delivery Status Notification (DSN): Provides standard notifications to the sender of the e-mail message that specifies whether or not the e-mail messages are delivered to end users.

When you connect to a mail server using an SMTP connection, various ESMTP parameters are displayed on the Web browser

The Metabase control helps control the messages delivered using ESMTP with the help of various ESMTP parameters.

Note 

Metabase is a structure that stores the settings of the Internet Information Server (IIS).

The metabase control stores the settings of IIS, which contains the login information of different clients on the Internet. You can use ESMTP to authenticate an end user through the login information stored in IIS.

Kerberos Modules

Kerberos is an authentication protocol that provides a method for authentication between a server and a client. The Kerberos protocol contains three different entities, which are used in the authentication method. These entities are: a client computer, a server computer, and the Kerberos Key Distribution Center (KDC) service. KDC is a service that enables an end user of a client computer to access a server using the Kerberos protocol.

You can use the shared-secret keys to authenticate end users to access a server using the Kerberos protocol. A shared-secret key is an encrypted password that is known to the end users communicating in a network. There are various types of shared-secret keys in Kerberos, such as long-term symmetric key, long-term asymmetric key, and short-term symmetric key.

You can use the cryptographic function of the long-term symmetric key, to convert the plain text password to a cryptographic key.

The advantages of using the Kerberos protocol are:

Interoperability: Supports authentication of end users on different platforms.

Delegated authentication: Provides the information required by a service to represent a client locally. The Kerberos protocol includes a proxy mechanism, which enables a service to represent its client locally when the service connects to other services on a network.

Efficient authentication to servers: Provides authentication without connecting to a domain server. Using the Kerberos protocol, an application server does not need to connect to a domain controller to authenticate each client on the network. The application server can authenticate a client on the basis of the credentials of the client.

Mutual authentication: Helps the server to identify a client computer on the network, and vice-versa.

Working with PAM Modules in Linux

PAM is a collection of modules, which control the authentication and authorization process in Linux. These modules help an administrator to add new methods of authentication to applications or services to authenticate and authorize end users accessing these applications and services. The administrator can install a PAM module to add the new methods of authentication, and modify the PAM configuration files to change the authentication policies.

Installing and Configuring PAM

To install PAM, you need to download the PAM package from the Web site, http://www.linuxfromscratch.org/blfs/view/stable/postlfs/linux_pam.html, and enter the following command at the command line:

rpm -ivh ldap_pam

After installing PAM, you need to store the configuration files of PAM, such as chfn, chsh, and login, in the /etc/pam.d directory. Configuration files of PAM contain the authentication configuration of PAM. The syntax of a PAM configuration file is:

type control module-path module-arguments

The four tokens defined in the above syntax are:

type: Specifies the type of authentication to be used for a PAM module. PAM supports four types of authentication, which are:

account: Identifies whether or not an end user can access a service, and if the password of an end user has expired.

auth: Identifies an end user by the unique password assigned to the end user.

Using passwords: Provides a method to change the password for authentication of an end user.

control: Specifies the access control if the authentication of an end user fails. PAM supports four types of control:

requisite: Denies access to the requested resources when the authentication through the requisite control fails.

required: Denies access to the requested resources when the authentication through the required control fails. PAM can call all other controls, such as the requisite control before denying the access.

sufficient: Grants access to the requested resources, if the authentication by the current module is successful, even if the authentication of the required control fails.

optional: Represents an optional control, which depend on the success and failure of an authorization if this is the only module used to authorize end users.

module-path: Specifies the name and location of the module to be used for authentication. The default location of PAM modules is /lib/security.

module-arguments: Represents the distinct arguments that are passed to a PAM module.

You can configure the parameters of the PAM modules to authorize end users, by using the Login configuration file to authenticate and authorize end users. The Login configuration file is stored in the /etc/pam.d directory.

Listing 7-1 shows the parameters of the Login configuration file:

Listing 7-1: Parameters of the Login Configuration File

#%PAM-1.0
auth     required   pam_securetty.so
auth     required   pam_stack.so service=system-auth
auth     required   pam_nologin.so
account  required   pam_stack.so service=system-auth
password required   pam_stack.so service=system-auth
session  required   pam_stack.so service=system-auth
session  optional   pam_console.so

The parameters in the above listing are:

auth, account, password, and session: Represent the types token.

required and optional: Represent the controls token.

pam_stack.so and pam_console.so: Represent the module paths token.

service=system-auth: Represents the module argument token.

Using PAM for Security

PAM integrates various authentication techniques, such as authenticating using login and password, into the system services to change the default authentication technique of a system. For example, the pam_ldap module, which is defined in the pam_ldap.so shared library, provides user and group authentication using an LDAP service.

Note 

The system services integrated with PAM authentication techniques are LDAP and UNIX.

You need to configure each system service through the PAM configuration files, to use different types of authentication techniques. You can use Secure Socket Layer (SSL) between a client and a server to encrypt passwords of the client and the server. SSL is an interface between the LDAP server and the PAM modules. SSL enables the client or the PAM modules to identify a server to authenticate end users to access the server.

Working with pam_ldap Module

The pam_ldap module is a PAM module that you can install and compile on the system, which supports the PAM API. You can use the pam_ldap module to authenticate and manage the passwords for authenticating the LDAP users. The advantages of using the pam_ldap module for authentication are:

Uses SSL to encrypt the transactions between a client and the LDAP server.

Uses the PAM Application Programming Interface for authentication.

Shares information related to the configuration, with other PAM modules.

Supports host-based and group-based logon information.

LDAP Libraries for the pam_ldap Module

The LDAP libraries for the pam_ldap module help to define authentication policies for LDAP authentication. Some examples of LDAP libraries are Netscape LDAP Software Development Kit (SDK) for C programming language, Mozilla LDAP package from Concurrent Versioning System (CVS), and OpenLDAP libraries.

Netscape LDAP SDK for C programming language is an SDK that contains the header files, library files, tools, and sample programs of C programming language. The header files of C programming language included in LDAP SDK for C are:

ldap_ssl.h: Provides SSL functions and structures contained in LDAP SDK for C.

ldap.h: Provides the standard functions and structurescontained in LDAP SDK for C.

lber.h: Provides the standard Basic Encoding Rules (BER) functions and structures for LDAP SDK for C.

ldappr.h: Provides the functions and structures contained in Netscape Portable Runtime (NSPR), for the LDAP SDK for C.

The library files of C programming language included in LDAP SDK for C are:

libnspr3.so: Contains the core NSPR functions.

libldapss141.sl: Is an SSL-enabled library for Hewlett Packard implementation of UNIX (HP-UX).

libldapss141.so: Is an SSL-enabled library for Solaris and Linux.

nsldapss132v41.dll: Is an SSL-enabled Dynamic Link Library (DLL) library for Microsoft Windows.

nsldapss132v41.lib: Is an SSL-enabled import library for 32-bit Microsoft Windows.

libnspr3.sl: Contains the core NSPR functions for HP-UX.

nsldap32v41bc.lib: Is a standard import library for 32-bit Microsoft Windows, which can be used with Borland compilers.

libnspr3.dll: Contains the core NSPR functions specific to Windows NT and Windows 2000.

The tools of C programming language provided with LDAP SDK for C are:

ldapsearch: Helps to search for entries in a directory and returns attributes and values of the entries.

ldapmodify: Helps to add, modify, or rename directory entries.

ldapcmp: Helps to compare directory entries of different directory servers.

ldapdelete: Helps to delete existing entries.

The sample programs that are provided with LDAP SDK for C are of two types, synchronous programs and asynchronous programs. The synchronous programs provided with LDAP SDK for C are:

csearch.c: Enables an in-memory cache and is similar to the search.c program.

srvrsort.c: Displays how to use server side sorting with the ldap_search_ext_c() function, which searches a directory.

search.c: Displays how to use the ldap_search_s() function to search for the entries in a directory.

rdentry.c: Displays how to use the ldap_search_s() function to retrieve an entry from a directory.

getattrs.c: Displays how to use the ldap_search_s() function to retrieve the attributes of an entry from the directory.

ssnoauth.c: Searches for an entry in an SSL protected TCP connection.

modrdn.c: Displays how to use the ldap_modrdn2_s() function to change the relative distinguished name (rdn) of an entry.

modattrs.c: Displays how to use the ldap_modify_s() function to replace and add values to an attribute of an entry.

compare.c: Displays how to use the ldap_compare_s() function to verify the value of an attribute of an entry.

getfilt.c: Displays how to use the ldap_getfilter*() functions, which generate LDAP filters based on a search stringspecified by an end user. The LDAP filters helps filter the content of LDAP database.

crtfilt.c: Displays how to use the ldap_create_filter() function to generate LDAP filters.

The asynchronous programs provided with LDAP SDK for C are:

add.c: Adds an entry to a directory.

psearch.c: Displays how to use Persistent Search to monitor the changes in a directory server.

ppolicy.c: Displays how a client can process password policy information.

asearch.c: Initiates a search for entries and displays the result of the search.

del.c: Deletes an entry from a directory.

Authenticating Users Using the pam_ldap module

The pam_ldap module uses various modules that support authentication, password management, and end user account management, such as:

LDAP authentication module

LDAP account management module

LDAP password management module

The pam_ldap module implements the pam_sm_setcred, pam_sm_authenticate, pam_sm_chauthtok, and pam_sm_acct_mgmt functions that help in PAM authentication, end user account management, and password management.

LDAP Authentication Module

The LDAP authentication module verifies an end user using the pam_sm_authenticate function. This function is defined in the profile of the client end user and is configured using the ldapclient command at the command line. When an end user enters a password, the pam_sm_authenticate function verifies the password to authenticate the end user to access the LDAP server. The LDAP authentication module returns the following messages:

PAM_BUF_ERR: Specifies an error in the buffer of the memory.

PAM_MAXTRIES: Specifies that the maximum number of attempts to authenticate an end user is exceeded.

PAM_USER_UNKNOWN: Specifies that the account for the end user does not exist.

PAM_AUTH_ERR: Specifies the authentication failure, which means that the end user is not authorized to access the LDAP server.

PAM_SUCCESS: Specifies that the authentication of en end user is successful.

PAM_SYSTEM_ERR: Specifies an error in the system files.

You can implement the pam_ldap module by configuring the login services. A Login service defines the user logon process authentication method and restrictions on a user account. You need to modify the pam.conf file to configure the login services.

Listing 7-2 shows how to configure the login service to implement using the pam_ldap module:

Listing 7-2: Configuring the Login Service in the pam.conf File

# Authentication management for login service.
# pam_ldap is not invoked, if pam_unix_auth
# succeeds. The control flag "binding" provides
# a local overriding remote (LDAP) control.  The
# "server_policy" option instructs
# pam_unix_auth.so.1 to ignore the LDAP users.
login auth requisite pam_authtok_get.so.1
login auth required pam_dhkeys.so.1
login auth binding pam_unix_auth.so.1 server_policy
login auth required pam_ldap.so.1

The above listing shows the login authentication configuration of the pam_ldap module.

LDAP Account Management Module

The LDAP account management module validates the account information of an end user using the pam_sm_acct_mgmt function. This function verifies all the information related to an end user account, before authenticating an end user to access the LDAP server. The pam_sm_acct_mgmt function verifies whether the password of an end user is expired or not. It also checks if the end user account is locked or not. The LDAP account management returns the following messages, including the PAM_BUF_ERR and the PAM_SYSTEM_ERR messages:

PAM_NEW_AUTHTOK_REQD: Specifies that a new authentication token is required.

PAM_ACCT_EXPIRED: Specifies that the account of an end user has expired.

PAM_SUCCESS: Specifies that an end user can access the account.

PAM_USER_UNKNOWN: Specifies that the account of an end user does not exist.

PAM_PERM_DENIED: Specifies that an end user is denied access to the account at a specific time.

You can configure the LDAP account management module to implement the pam_ldap module to authenticate user accounts.

Listing 7-3 shows how to configure the account management module:

Listing 7-3: Configuring the LDAP Account Management Module

# Account management for all services.
# pam_ldap is not invoked, if pam_unix_account
# succeeds. The control flag "binding" provides
# a local overriding remote (LDAP) control. The
# "server_policy" option instructs
# pam_unix_account.so.1 to ignore the LDAP users.
other account requisite pam_roles.so.1
other account required pam_projects.so.1
other account binding pam_unix_account.so.1 server_policy
other account required pam_ldap.so.1

The above listing shows the user-account authentication configuration of the pam_ldap module.

LDAP Password Management Module

The LDAP password management module helps to specify a new password or modify the existing password that authenticates an end user to access the LDAP server. You can use the pam_authtok_store function to modify the existing password. The pam_authtok_store function updates the modified password in all the registries. If you use the pam_sm_chauthtok function to modify the password, only the LDAP database is updated with the modified password. The LDAP password management module returns the following messages, including the PAM_BUF_ERR and the PAM_SYSTEM_ERR messages:

PAM_PREM_DENIED: Specifies that there is no permission to update the authentication token.

PAM_SUCCESS: Specifies that the authentication token is updated successfully.

PAM_USER_UNKNOWN: Specifies that the account of an end user does not exist.

PAM_AUTHTOK_ERR: Specifies an error in manipulation of the authentication token.

You can configure the LDAP password management module to implement pam_ldap module for the passwords.

Listing 7-4 shows how to configure the password management module:

Listing 7-4: Configuring the LDAP Password Management Module

# Password management for authentication
passwd  auth binding  pam_passwd_auth.so.1 server_policy
passwd  auth required pam_ldap.so.1
# Password management for updates
# it updates passwords stored both in the local
# /etc files and in the LDAP directory. The
# "server_policy" option instructs
# pam_authtok_store to follow the LDAP server's
# policy when updating passwords stored in the
# LDAP directory
other password required pam_dhkeys.so.1
other password requisite pam_authtok_get.so.1
other password requisite pam_authtok_check.so.1
other password required pam_authtok_store.so.1 server_policy

The above listing shows the password management configuration for local and LDAP accounts.

You can also configure the password management for remote accounts.

Listing 7-5 shows the configuration for password management for remote accounts, using the pam_ldap module:

Listing 7-5: Configuring the LDAP Password Management Module for Remote Accounts

# Password management for authentication
# The control flag "binding" provides a local
# overriding remote (LDAP) control. The
# server_policy option instructs
# pam_passwd_auth.so.1 to ignore the LDAP users.
passwd auth binding  pam_passwd_auth.so.1 server_policy
passwd auth required pam_ldap.so.1
# Password management for updates
# This stack is limited to updating password
#stored in the LDAP directory.
other password required  pam_ldap.so.1

The above listing shows the password management configuration for remote accounts.

Chapter 8: Migrating Calendar Services

A calendar service transports personal calendaring information between e-mail messages or Web browsers. You can broadcast an e-mail message with a calendar attachment to all the end users who need to attend the meeting that is scheduled in the calendar. Each of the invitees receives the e-mail message, selects the calendar attachment, and moves the attachment to their scheduling application. As a result, all the information related to the meeting, such as date, time, and location are automatically added to the calendar of each invitee.

This chapter introduces the calendar services in Microsoft Exchange Server and qmail. It also describes how to migrate the calendar services from Microsoft Exchange Server to qmail.

Working with the Calendaring System in Exchange Server and qmail

A calendar is used to exchange information about the events and to-do items of calendaring and scheduling entities. The information about the events and to-do items are used by applications, such as Personal Information Manager (PIM) and group schedulers to manage the information about the scheduling of events and to-do items. An event is a calendaring and scheduling entity that represents the scheduled time on a calendar. For example, an event can be an hour meeting of employees of a department, scheduled for this weekend. A to-do item is a calendaring and scheduling entity that represents an action item. For example, a to-do can be the amount of work assigned to an individual.

Microsoft Exchange provides various services, such as e-mail, calendar, and address book to schedule tasks of the end users. Microsoft Outlook uses Microsoft Exchange to work with its services.

Calendaring in Exchange Server

You can use the calendar service of Exchange Server to schedule appointments, meetings, and events. You can also customize the settings of a calendar and save the calendar as a Web page. You need to click the Calendar icon from the Outlook Shortcuts list on the Microsoft Outlook window, to view the calendar services, as shown in Figure 8-1:

Click To expand: This figure shows the Calendar page in which all the scheduled appointments, meetings, and events are displayed.
Figure 8-1: The Calendar Page

An appointment is a non-interactive activity, which does not need an interaction with end users. You can set the reminders for appointments and schedule the recurring appointments, which repeat on a regular basis. To create an appointment:

Select File -> New -> Appointments from Microsoft Outlook to open the Meeting-Appointment window, as shown in Figure 8-2:

Click To expand: This figure shows the screen in which you can specify the subject and location for the appointment. You can also specify the start and end time for the meeting.
Figure 8-2: The Meeting-Appointment Window

Enter the subject of the appointment in the Subject text box.

Enter the location of the scheduled appointment in the Location text box.

Select the start time from the Start time drop-down list box and the end time from the End time drop-down list box to specify the duration of the appointment.

Click the Recurrence icon if the appointment is recurring. The Appointment Recurrence Window appears, as shown in Figure 8-3:

Click To expand: This figure shows that the appointment is recurring on every Sunday at 10.00 AM.
Figure 8-3: The Appointment Recurrence Window

Specify the pattern in the Recurrence pattern option to create the recurring appointment according to the specified pattern. Click OK to create the recurring appointment.

Click the Save and Close icon on the Meeting-Appointment window to create an appointment.

You can set the reminders for the appointments in a calendar. To set the reminder for the appointment:

Open the appointment for which you want to set the reminder, as shown in Figure 8-4:

Click To expand: This figure shows the screen in which you need to select the Reminder check box for setting a reminder for the meeting.
Figure 8-4: The Meeting-Appointment Window for Setting Reminders

Select the Reminder check box and enter the time to run the reminder before the appointment.

Click the Sound button to open the Reminder Sound dialog box, as shown in Figure 8-5:

Click To expand: This figure shows the text box in which you can specify the location for the sound files.
Figure 8-5: The Reminder Sound Dialog Box

Specify the path of the sound files using the Browse button to play the selected sound as a reminder before the appointment.

A meeting is an interactive activity that needs interaction with the end users. To schedule a meeting:

Click the Calendar icon from the Outlook Shortcuts list to schedule a meeting in a calendar.

Select Actions -> Plan a Meeting to open the Plan a Meeting dialog box, as shown in Figure 8-6:

Click To expand: This figure shows the screen in which you need to add the name of the attendees for the meeting.
Figure 8-6: The Plan a Meeting Dialog Box

Click Invite Others to add the name of the attendees for the meeting. The Select Attendees and Resources dialog box appears, as shown in Figure 8-7:

Figure 8-7: The Select Attendees and Resources Dialog Box

Select the name of the attendees from Select from List and click the Required, Optional, or Resources button to specify the type of attendees.

Click OK and select the time for meeting in the Plan a Meeting dialog box, as shown in Figure 8-8:

Click To expand: This figure shows that the start time for the meeting is 4:00 PM and end time for the meeting is 4:30 PM.
Figure 8-8: Selecting the Time for Meeting

Click the Make Meeting button to open the Meeting window, as shown in Figure 8-9:

Click To expand: This figure shows that the invitations have not been sent for the meeting.
Figure 8-9: The Meeting Window

Enter a subject for the meeting in the Subject text box and enter a location for the meeting in the Location text box.

Click the Send icon to send the invitations to all the attendees for the meeting.

An event is an activity that occurs in last 24 hours or more. It can occur daily, weekly, monthly, or yearly. For example, birthday and anniversary are the annual events that occur on a specific date. To create an event:

Click Calendar icon from the Outlook Shortcuts list to create an event in calendar.

Select Actions -> New All Day Event to open the Event window, as shown in Figure 8-10:

Figure 8-10: The Event Window

Enter the description and location of the event in the Subject and Location text boxes.

Click the Recurrence icon to add the recurrence event. The Appointment Recurrence dialog appears, as shown in Figure 8-11:

Click To expand: This figure shows the various recurrence patterns, such as Daily, Weekly, Monthly, and Yearly.
Figure 8-11: The Appointment Recurrence Dialog Box

Select the Yearly option to specify the annual event. Click OK to return to the Event window.

Click Save and Close to add an event. The Calendar page appears, as shown in Figure 8-12:

Click To expand: This figure shows that the annual event, Birthday is displayed on the top of the Calendar page.
Figure 8-12: Displaying the Annual Event on the Calendar Page

Calendaring in qmail

The Calendaring feature in qmail allows you to store and manage the appointments. This feature also allows you to create a to-do list, which specifies a list of tasks to be done. You can use the Calendaring feature in qmail through the Ximian Evolution tool in Linux. To create an appointment using the Calendaring feature of the Ximian Evolution tool:

Open the Ximian Evolution window.

Click the Calendar icon on the left pane of the Ximian Evolution window to open the Calendar page, as shown in Figure 8-13:

Click To expand: This figure shows the various options of the calendar in the Ximian Evolution tool.
Figure 8-13: The Calendar Page in Ximian Evolution

Select File -> New -> Appointment, to open the Appointment window.

Enter the summary of the appointment in the Summary text box of the Appointment window.

Enter the location for the appointment in the Location text box of the Appointment window.

Enter the starting date and time in the Start time drop-down list box of the Appointment window.

Enter the end date and time in the End time drop-down list box of the Appointment window, as shown in Figure 8-14:

Click To expand: This figure shows the details of an appointment with the options, such as Classification and Show Time as. These options help to manage the appointments.
Figure 8-14: The Appointment Window

Select File -> Save and Close to save the appointment schedule, as shown in Figure 8-15:

Click To expand: This figure shows two appointments for a specific date, on the calendar.
Figure 8-15: The Appointments Added on The Calendar Page

You can also set reminders in the form of a message or alarm, to remind you of an appointment. To set a reminder for an appointment:

Open the Appointment window.

Click the Reminder tab to open the Reminder page of the Appointment window.

Specify the reminder in the Reminders pane of the Reminder page.

Click Add to add the reminder for an appointment in the Reminders pane, as shown in Figure 8-16:

Click To expand: This figure shows one reminder to display a message before an appointment.
Figure 8-16: The Reminder Page

Select File -> Save and Close to save the reminder and close the Appointment window.

To schedule a meeting to interact with different end users:

Open the Ximian Evolution window.

Select File -> New -> Meeting to open the Meeting page of the Appointment window, as shown in Figure 8-17:

Click To expand: This figure shows different properties, such as Attendee, Type, and status that help to identify an attendee of a meeting.
Figure 8-17: The Meeting Page

Click the Click here to add an attendee text box to add the particulars of a person.

Enter the name of the attendee in the Attendee text box.

Select the type of attendee from the Type drop-down list box.

Select the role of the attendee from the Role drop-down list box.

Select the Yes or No option from the RSVP drop-down list box.

Select the status of the attendee from the Status drop-down list box.

Figure 8-18 shows the properties of the attendee, Joe Smith:

Click To expand: This figure shows that Joe Smith is an individual attendee and the presence of Joe Smith in the meeting is optional.
Figure 8-18: The Meeting Properties of Joe Smith

Select File -> Save and Close to save the meeting and close the Appointment window.

A task helps you to manage the work on the basis of priority of the task. You can use the Calendaring feature in qmail to create and manage a list of tasks. To add a new task:

Open the Ximian Evolution window.

Select File -> New -> Task, to open the Task window.

Enter the summary of the task in the Summary text box of the Task window.

Specify the due and start date of the task in the Due date and Start date drop-down list boxes of the Task window.

Figure 8-19 shows the details of a task in the Task window:

Click To expand: This figure shows the details of a task, such as the due date, the start date, and the description of the task.
Figure 8-19: The Task Window

Select File -> Save and Close to save the task and close the Task window.

Figure 8-20 shows the summary of the appointments and tasks:

Click To expand: This figure shows the complete list of appointments and tasks added in the calendar of the Ximian Evolution tool.
Figure 8-20: The Summary Window

Tools to Convert Calendars

You can convert the existing calendars of MS-Outlook into the calendars of the Ximian Evolution tool by using either the MUA or the third party tools. If you are using an MUA to convert the calendar, you need to save each schedule of the calendar separately. These saved schedules are then imported into calendar of the Ximian Evolution tool by using its Import feature. Alternatively, if you are using a third party tool, you can simultaneously convert all the schedules of an MS Outlook calendar into the calendar of the Ximian Evolution tool.

You can use various tools and macros, such as the outlook2ical macro, to export the schedules of a calendar from the MS Outlook calendar to Ximian Evolution calendar. You need to save a calendar schedule in one of the standard calendar formats, such as .ics or .vcs for converting the Outlook calendar into a calendar of the Ximian Evolution tool. To install the outlook2ical macro:

Download the Visual Basic (VB) zipped files from http://www2.et.byu.edu/~njones/share/outlook2ical/.

Unzip the downloaded VB files on the hard disk of your computer.

Open the MS Outlook window.

Select Tools -> Macro -> Security to open the Security dialog box.

Select the Medium option from the Security level tab of the Security dialog box, as shown in Figure 8-21:

Click To expand: This figure shows the different levels of security, such as Very High, High, Medium, and Low that define the security level of macros.
Figure 8-21: The Security Dialog Box

Click OK to apply the security level.

Select Tools -> Macro -> Visual Basic Editor to open the VB editor window.

Open the Project Explorer window in the VB editor window.

Right-click the Microsoft Office Outlook Objects icon in the Project explorer window to open a shortcut menu.

Select the Import File option from the shortcut menu to open the Import File dialog box.

Select the frmSaveiCalStep1.frm file from the Import File dialog box.

Click Open to import the frmSaveiCalStep1.frm file in the Project Explorer window.

Import the frmSaveiCalStep2.frm file to the Project Explorer window.

Import the frmSaveiCalStep3.frm file to the Project Explorer window.

Import the clsFTP.cls file to the Project Explorer window.

Import the icalendar.bas file to the Project Explorer window.

Close the VB editor window.

Close the MS Outlook window.

You can use the outlook2ical macro to export the schedules of a calendar from MS Outlook. To export the schedules from MS Outlook to Ximian Evolution:

Open the MS Outlook window.

Select Tools -> Macro -> Macros to open the Macros dialog box, as shown in Figure 8-22:

Click To expand: This figure shows the name of the outlook2ical macro. You can select the macro name from the macro list.
Figure 8-22: The Macros Dialog Box

Select the export_icalendar macro from the Macro Name list box in the Macros dialog box.

Click Run to open the Save iCal-Step 1/3 screen of the Save iCal wizard, as shown in Figure 8-23:

Click To expand: This figure shows that you can export the default calendar or you can also select a specific calendar from the Select Calendar button.
Figure 8-23: The Save iCal Step 1/3 Screen

Select the Default calendar option from the Select Calendar to Export list.

Click Next on the Save iCal Step 1/3 screen to open the Save iCal Step 2/3 screen.

Select the Export all appointments in calendar option on the Save iCal Step 2/3 screen, as shown in Figure 8-24:

Click To expand: This figure shows the categories of the appointments that you can export.
Figure 8-24: The Save iCal Step 2/3 Screen

Click Next to open the Save iCal Step 3/3 screen, as shown in Figure 8-25:

Click To expand: This figure shows the options to specify the location where you can export the calendar appointments.
Figure 8-25: The Save iCal Step 1/3 Screen for Specifying Location

Enter the name of the host in the Host name text box of the Save iCal Step 3/3 screen.

Enter the user name in the User name text box of the Save iCal Step 3/3 screen.

Enter the password in the Password text box of the Save iCal Step 3/3 screen.

Enter the name of the file in the Remote file name text box of the Save iCal Step 3/3 screen.

Enter the path of the file in the Remote subdirectory text box of the Save iCal Step 3/3 screen.

Click Finish to close the Save iCal wizard.

You can save the schedule in the local hard disk of the computer that contains the Ximian Evolution. You can import the schedule in the calendar of the Ximian Evolution using the Import File option. To import the schedule to the Ximian Evolution calendar:

Open the Ximian Evolution window.

Select File -> Import to open the Evolution Import Assistant.

Click Forward to open the Importer Type screen.

Select the Import a Single File option from the Importer Type screen.

Click Forward to open the Select a File screen.

Specify the location and name of the file in the File name text box of the Select a File screen.

Select the iCalendar files (.ics) option from the File type drop-down list box, as shown in Figure 8-26:

Click To expand: This figure shows that you can specify the path of the file and its type in the Select a File screen.
Figure 8-26: The Select a Continue List screen.

Click Forward to open the Import File screen.

Click Import on the Import File screen to open the Select a Folder dialog box, as shown in Figure 8-27:

Click To expand: This figure shows the list of folders, in which you can import the appointment calendar.
Figure 8-27: The Select a Folder Dialog Box

Select the name of the folder in the Select Folder dialog box.

Click OK to import the schedule1.ics file to the Ximian Evolution calendar.

Chapter 9: Configuring qmail

qmail is a Message Transfer Agent (MTA) designed for the UNIX operating system. qmail uses Simple Mail Transfer Protocol (SMTP) to transfer the e-mail messages to other MTAs on different computers.

After installing qmail, you need to configure it so that qmail can send and receive e-mail messages to and from different MTAs. You can configure qmail by creating the configuration files, aliases, and the remote control (rc) files.

This chapter describes how to configure qmail using the configuration files of qmail. It also describes how to create and manage the mailing lists and how to configure the Post Office Protocol (POP) for qmail.

Configuration Files

Configuration files define different settings to enable qmail to send and receive the e-mail messages using qmail modules, such as qmail-send or qmail-smtpd. In addition, you can modify the settings of qmail using the configuration files. These configuration files are stored at the \var\qmail\control location.

Describing Configuration Files

Configuration files use the qmail modules and enable the qmail mail server to send and receive the e-mail messages. The different qmail modules are:

qmail-send

qmail-smtpd

qmail-inject

qmail-remote

The qmail-send module delivers e-mail messages to the remote computers using the qmail-queue module. The configuration files that use the qmail-send module are listed in Table 9-1:

Table 9-1: Configuration Files that use the qmail-send Module

Configuration File

Default Value

Purpose of Configuration File

bouncefrom

MAILER-DAEMON

Stores the name of the end user, whose e-mail message is undelivered.

bouncehost

Me

Stores the name of the host, whose e-mail message is undelivered.

concurrencylocal

10

Stores the maximum number of simultaneous e-mail messages sent to local computers.

Concurrencremote

20

Stores the maximum number of simultaneous e-mail messages sent to remote computers.

Doublebouncehost

Me

Stores the host name of a domain, which contains a double bounce file to store the undelivered messages.

Doublebounceto

Postmaster

Stores the name of the end user who receives double bouncers. A double bouncer is a file that stores the undelivered e-mail messages.

Envnoathost

Me

Stores the default domain name of the hosts containing the e-mail addresses without the @ symbol.

Locals

Me

Stores the name of domains, from which the e-mail messages are delivered to a local computer.

Percenthack

None

Stores the name of domains that can use the % sign.

Queuelifetime

604800

Stores the total time for which a message can remain in a queue.

Virtualdomains

None

Stores the name of virtual domains and end users.

Note 

The qmail-queue module helps arrange the e-mail messages sequentially for delivery to the remote computers.

The qmail-smtpd module receives and stores the e-mail messages through SMTP in a queue containing the outgoing messages. The configuration files that use the qmail-smtpd module are listed in Table 9-2:

Table 9-2: Configuration Files that use the qmail-smtpd Module

Configuration File

Default Value

Purpose of Configuration File

Badmailfrom

None

Stores the e-mail addresses of the rejected e-mail messages.

Databytes

0

Specifies maximum number of bytes that an e-mail message can store. The 0 value specified in this file denotes no limit for a message.

Localiphost

Me

Stores the alternative name for the local IP address.

Morercpthosts

None

Stores the secondary rcpthosts database.

Rcpthosts

None

Stores the name of domains for which the e-mail messages are accepted.

Smtpgreeting

Me

Stores the name of the default domain in an e-mail message.

Timeoutsmtpd

1200

Stores the time for which the server waits for getting a response from the SMTP client.

The qmail-inject module reads an e-mail message, adds more information to the header of the message, and sends the message to more than one recipient through qmail-queue. The configuration files that use the qmail-inject module are listed in Table 9-3:

Table 9-3: Configuration Files that Use the qmail-inject Module

Configuration File

Default Value

Purpose of Configuration File

Defaultdomain

Me

Stores the default domain name.

Defaulthost

Me

Stores the default host name.

Idhost

Me

Stores the host name, from where a message is received.

Plusdomain

Me

Stores the domain name that is substituted for the + sign, which appears after the name of the host.

The qmail-remote module reads an e-mail message and delivers the message to more than one recipient on a remote host. The configuration files that use the qmail-remote module are listed in Table 9-4:

Table 9-4: Configuration Files that Use the qmail-remote Module

Configuration File

Default Value

Purpose of Configuration File

Helohost

Me

Stores the host name used as a parameter in the SMTP HELO command.

Smtproutes

None

Stores the artificial SMTP routes.

Timeoutconnect

60

Stores the total time, for which a server waits to connect to the SMTP client.

Timeoutremote

1200

Stores the total time, for which a client waits for a response from a remote server.

There are various configuration files that cannot be grouped in any module. These configuration files are listed in Table 9-5:

Table 9-5: Configuration Files in Other Modules

Configuration File

Default Value

qmail Module

Purpose of Configuration File

Concurrencyincomming

None

/Service/qmail-smtpd/run

Stores the maximum number of simultaneous incoming requests for SMTP connections.

Defaultdelivery

None

/Var/qmail/rc

Stores the name of the default .qmail file.

Me

FQDN of system

Various

Stores the default name of a domain.

Qmqpservers

None

qmail-qmqpc

Stores the IP addresses of the Quick Mail Queueing Protocol (QMQP) servers.

Note 

QMQP is a protocol used by clients for queuing e-mail messages to a host that handles the mail delivery.

Modifying Configuration Files

You need to change the default value of the configuration files to change the configuration settings of qmail. As a result, a mail server can send and receive different types of e-mail messages from different e-mail addresses. For example, if you change the value of the badmailfrom configuration file from None to xz@abc.com, the qmail mail server rejects the e-mail messages received from the xz@abc.com e-mail address.

You need to edit the following configuration files to configure the qmail-send module:

bouncefrom: Enter the e-mail address parameter in this configuration file using the vi editor, to display a message when an e-mail message received from an e-mail address is rejected.

bouncehost: Enter the domain names parameter in the bouncehost configuration file to display a message when an e-mail message received from the domain is not delivered.

concurrencylocal: Enter a number parameter in this configuration file, to limit the number of concurrent deliveries of messages to a local computer.

concurrencyremote: Enter a number parameter in this configuration file, to limit the number of concurrent deliveries of messages to a remote computer.

doublebouncehost: Enter the domain name parameter in the doublebouncehost configuration file to display a message about the undeliverable or bounced messages.

doublebounceto: Enter the doublebounce-handler parameter in the doublebounceto configuration file to display a message about the undeliverable bounced messages, which you send to a local host.

envnoathost: Enter the domain name parameter in the envnoathost configuration file to append the domain name in a way that you can change the recipient address, if the address does not contain the @ symbol.

locals: Enter the names of local host parameters in the locals configuration file to define the aliases for a local host.

percenthack: Enter the route of an e-mail message as a parameter in the percenthack configuration file, to allow the e-mail addresses to use the route.

queuelifetime: Enter the number of seconds parameter in the queuelifetime configuration file to specify the maximum length of time for which a temporarily undeliverable e-mail message can remain in the queue. The queue of e-mail messages is deleted when the time specified in this file is over.

virtualdomains: Enter the name of a virtual domain and local domain parameters in the virtualdomains configuration file to create the virtual domain on the local domain.

To configure the qmail-smtpd module, you need to edit the following configuration files:

badmailfrom: Enter a list of e-mail addresses or the domain names, in the badmailfrom.cdb configuration file, to reject the e-mail messages received from the e-mail addresses and the addresses of the domain name specified in the badmailfrom file.

databytes: Enter the number of bytes a message can store in the databytes configuration file, to limit the number of SMTP local e-mail messages and the e-mail messages from a remote host.

localiphost: Enter a host name in the localiphost configuration file, to replace the local IP address with the host name specified in the localiphost file.

morercpthosts: Enter the echo "hostname" > /var/qmail/control/morercpthost and the qmail-newmrh parameters to add a host name to the morercpthosts configuration file.

rcpthosts: Enter the name of domains contained in the locals and virtualdomain configuration files.

smtpgreeting: Enter the parameter, <hostname> -= NO UNSOLICITED BULK EMAIL =-, in the smtpgreeting configuration file, to display a warning message when an unauthorized end user tries to hack the hostname specified in the smtpgreeting configuration file.

timeoutsmtpd: Enter the time in seconds in the timeoutsmtpd configuration file, to limit the time of the connection with the SMTP client.

To configure the qmail-inject module, you need to edit the following configuration files:

defaultdomain: Enter the name of a domain in the defaultdomain configuration file, which serves as the default domain.

defaulthost: Enter the name of the host, which serves as the default host, in the defaulthost configuration file.

idhost: Enter the name of a domain, which replaces the host name displayed in the MessageID field, in the idhost configuration file.

plusdomain: Enter the domain name, which substitutes the + symbol in an e-mail address, in the plusdomain configuration file.

To configure the qmail-remote module, you need to edit the following configuration files:

helohost: Enter the name of a remote host in the helohost file, to specify the host name used by the SMTP client in the HELO command.

smtproutes: Enter the name of a local host parameter in the smtproutes file, to forward the e-mail messages from the local host for the local domain, to the local hub.

timeoutconnect: Enter the time, in seconds, in the timeoutconnect file, to set the time for which qmail-remote will wait to establish a connection with a remote SMTP server.

timeoutremote: Enter the time, in seconds, in the timeoutremote file, to limit the time for each response from SMTP server.

To configure other modules, you need to edit the following configuration files:

concurrencyincomming: Enter the maximum number of concurrent SMTP connection requests in the concurrencyincomming file.

defaultdelivery: Enter the package name parameters in the defaultdelivery file, to send the messages through the package, and deliver the messages to the mailboxes at the /var/spool/mail/username location.

me: Enter the domain name in the me file to modify the name of the domain, if you rename your computer.

qmqpservers: Enter a sequence of IP addresses, to which the QMQP server contacts, in the qmqpservers file.

Allowing Selective Relaying

Relaying is the process of sending the e-mail messages through the SMTP mail server of a company. When a client sends an e-mail message through the SMTP mail server, the qmail-smtpd module checks the domain name of the recipient. If the domain name of the recipient is listed in the /var/qmail/control/rcpthosts file, qmail accepts the message otherwise, it rejects the message.

Selective relaying is a method used to relay the e-mail messages from a selected group of IP addresses. For selective relaying, you need to create the /var/qmail/control/rcpthosts file, and specify a list of host names or IP addresses from which qmail will accept the e-mail messages. To configure qmail for selective relaying:

Enter the following command at the command line. to create the /var/qmail/control/rcpthosts file:

sed 's/:.*//' < virtualdomains | cat - locals | sort > rcpthosts

The rcpthost stores the domain names to which the mail server relays the messages.

Specify the host names or IP addresses in the rcpthosts file using the vi editor, for selective relaying. For example, you can enter the following parameters in the rcpthosts file to specify the e-mail address of the end user, Arnold, and the domain name, qmail.solutions.com, in the file for selective relaying:

# The e-mail address of the end user, Arnold
arnold@qmail.solutions.com
# The domain name
qmail.solutions.com

The above entries enable selective relaying for the domain names and e-mail addresses specified in the rcpthosts file.

Create and save the /etc/tcp.smtp file by using the vi editor at the /usr/local/src/ucspi-tcp-0.88 location, to configure qmail for selective relaying by specifying IP addresses.

Enter the following parameters in the /etc/tcp.smtp file and save the file, to establish connections with the IP addresses specified in the /etc/tcp.smtp file, using the vi editor:

# You can receive the e-mail messages from the following IP addresses.
192.168.0.120:allow,RELAYCLIENT=""
192.:allow,RELAYCLIENT=""
:allow

Enter the following command at the command line to create the /etc/tcp.smtp.cdb file:

cat /etc/tcp.smtp | tcprules /etc/tcp.smtp.cdb ~/tcp.smtp.tmp

The /etc/tcp.smtp.cdb file is the compiled version of the /etc/tcp/smtp file that initiates selective relaying.

Enter the following command at the command line to display the information about the inetd process executed in the UNIX operating system:

ps -ax | grep inetd

Figure 9-1 shows the information about the inetd process:

Click To expand: This figure shows the information, such as the process ID and the connection time about the inetd process. You can use the process ID of the process to refer the process.
Figure 9-1: Information About the inetd Process

Enter the following command at the command line to stop the current process:

kill -HUP 3254

In the above command, 3245 is the process ID of the inetd process and the Hang UP (HUP) signalis used to stop this process. You need to stop this process to start selective relaying.

Enter the following command at the command line to initialize the tcp server:

/usr/local/bin/tcpserver -R -x/etc/tcp.smtp.cdb -c100 -u666 -g102 0 smtp \
/var/qmail/bin/qmail-smtpd &

Figure 9-2 shows the output of the above command:

Click To expand: This figure shows the information about the server, after the server has been initialized. You need to initialize the tcp server to enable the initialization of selective relaying.
Figure 9-2: Initialization of tcp Server

Enter the following command at the command line to initialize the selective relaying of the e-mail messages:

/var/qmail/bin/qmail-smtpd 2>&1 | /var/qmail/bin/splogger smtpd &

Figure 9-3 shows the initialization of selective relaying:

Click To expand: This figure shows the execution of the qmail-smtpd module, which initializes the process of selective relaying.
Figure 9-3: Initialization of Selective Relaying

Introducing Multiple Host Name and Virtual Domain

You need to specify the address to which you can deliver a message, when there is more than one host. For example, if the alternative names of the example.com host are mail.example.com, and host1.example.com, the example.com host receives the messages sent to either user@host1.example.com or user@mail.example.com,

When there are multiple domains on a server, each domain is referred to as a virtual domain. For example, if the name of the server is example.com, you can create virtual domains, such as my.example.com or your.example.com on this server.

Using Multiple Host Names

You can add multiple host names corresponding to a single host in the rcpthosts and locals files. As a result, the server running with qmail can accept messages sent to the host with multiple host names. Specifying the host names in the rcpthosts file instructs the qmail-smtpd module to accept messages addressed to the hosts listed in the rcpthosts file. Specifying the host names in the locals file instructs the qmail-send module to deliver the messages to the addresses of the hosts listed in the locals file.

After specifying the list of multiple host names for a single host in the rcpthosts and locals file, you need to send a HangUP (HUP) signal, which is used to stop a process, to the qmail-send configuration file. Enter the following command to send a HUP signal:

qmailctl reload

Figure 9-4 shows the output of the qmailctl reload command.

Click To expand: This figure shows the HUP signal being send to the qmail-send module.
Figure 9-4: Output of the qmailctl reload Command

Using Virtual Domains

Virtual domains are similar to the multiple host name domains. The difference between the virtual domains and the multiple host name domains is that the namespace for each virtual domain of a server is distinct but the namespaces for multiple host name domains is not distinct. To configure virtual domains in qmail:

Open the /etc/qmail/virtualdomains file to enter and save the following parameters in this file:

arnold@qmail.solutions.com: johnd

This parameter creates an entry for the end user, john.

Add the names of the virtual domains in the rcpthosts file.

Enter the following command at the command line to send a HUP signal to the qmail-send module:

qmailctl reload

qmail converts the e-mail address, arnold@qmail.solutions.com to the e-mail address, john-arnold@qmail.solutions.com. As a result, a message sent to the e-mail address, arnold@qmail.solutions.com, diverts to the e-mail address, john-arnold@qmail.solutions.com.

Creating and Managing Mailing Lists

Mailing list is a collection of e-mail addresses that can be referred by a single name. For example, the Addressbook mailing list contains the e-mail addresses, which are required to send the e-mail messages. You can create and manage the mailing lists in qmail by using a Mailing List Manager (MLM). The MLM manages the list of subscribers and the messages sent to the subscribers. The MLM helps create the mailing list by using commands, such as subscribe or unsubscribe. You can also create a mailing list by using the EZ Mailing List Manager (EZMLM). EZMLM is the MLM for qmail that sends a message to multiple recipients, and adds or removes the end users from the mailing list.

Using the EZ Mailing List Manager

You can use various EZMLM commands, such as subscribe or unsubscribe, or the EZMLM WEB tool, to create and manage a mailing list. The EZMLM commands are sent to the specific e-mail addresses, where the commands are executed. The EZMLM WEB tool is a web-based tool that helps to create and manage a mailing list by using different options, such as create mailing list or edit mailing list.

Using the EZMLM Commands

EZMLM uses the command line interface to create and maintain the mailing list. EZMLM contains different addresses for different commands. As a result, EZMLM executes a command when you send the message for the command to the corresponding address. The address of a command has two parts: the list name and the command. For example, the e-mail address, mail1-subscribe@exmple.com specifies that the message to subscribe an end user is being sent to the mail1 mailing list. The built-in addresses to which you can send a message for executing a command are:

mail1-subscribe@example.com: Specifies that the subscribe command is sent to the mail1 mailing list. This command subscribes you to a mailing list. EZMLM sends you a request to subscribe to the mailing list and when you reply to the request, you are subscribed to the mailing list.

mail1-unsubscribe@example.com: Specifies that the unsubscribe command is sent to the mail1 mailing list. This command unsubscribes you from a mailing list. EZMLM sends you a confirmation request and when you reply to the request, the mailing address is removed from the mailing list.

mail1-query@example.com (*): Specifies that the query command is sent to the mail1 mailing list. This command specifies an e-mail address of an end user subscribed to the mail1 mailing list.

mail1-get@example.com (*): Specifies that the get command is sent to the mail1mailing list. This command retrieves the current 30 messages from the mail1 mailing list.

mail1-get.120@example.com: Specifies that the get command is sent to the mail1mailing list. This command retrieves the message specified by the message number after the -get parameter. For example, the get command sent to mail1-get.120@example.com retrieves the message number 120 from the mail1 mailing list. If you specify the message number, which does not exist in a mailing list, you receive the last message of the mailing list.

mail1-get.45_67@example.com: Specifies that the get command is sent to the mail1mailing list. This command retrieves a range of message numbers specified after the -get parameter. For example, the get command sent to mail1-get.45_67@example.com retrieves the messages between 45 to 67 message numbers from the mail1 mailing list. A single request cannot retrieve more than 100 messages.

mail1-index@example.com (*): Specifies that the index command is sent to the mail1 mailing list. This command sends the author name and subject related to the messages of the mail1 mailing list to an end user.

mail1-index.200_400@example.com (*): Specifies that the index command is sent to the mail1 mailing list. This command sends the author name and subject to an end user, for the messages between 200 to 400 message numbers.

mail1-info@example.com (*): Specifies that the info command is sent to the mail1 mailing list. This command sends the information about the mail1 mailing list to an end user.

mail1-faq@example.com (*): Specifies that the faq command is sent to the mail1 mailing list. This command sends a list of frequently asked questions related to the mail1 mailing list to an end user.

Creating and Managing the Mailing Lists Using Commands

You can create a mailing list using commands, such as ezmlm-make, to send a message to the e-mail addresses stored in the mailing list. If you send a message to mail1@example.com, all the subscribers of the mail1 mailing list receive the message. You can use different commands to create and manage the mailing lists. Creating a mailing list involves:

Creating a discussion list.

Creating an announcement list.

Modifying the mailing list.

A discussion list is a Web-based list of the e-mail addresses that is used to deliver the e-mail messages directly to the inbox of the e-mail addresses specified in the list. The end users of the discussion list can interact with each other. This list helps all the subscribers of the mailing list to receive the e-mail messages sent to the mailing list. To create a discussion list:

Select Start -> Run to open the Run dialog box.

Enter Telnet in the Open text box of the Run dialog box to open the Telnet program.

Select Connect -> Remote System to open the Connect dialog box.

Enter the host name or IP address in the Host Name text box and click the Connect button to connect to the host.

Enter the following command at the command prompt to create the mail1 distribution list on abc.net domain:

cd
ezmlm-make ~/mail1 ~/.qmail-mail1 mail1 lists.abc.net

This command creates a discussion list, mail1 in the qmail-mail1 directory.

An announcement list is a Web-based list, in which a message is delivered to all the subscribers of a mailing list. The end users of the announcement list cannot interact with each other. The e-mail message is sent to the subscribers as a broadcast. To create an announcement list:

Create a discussion list.

Close the Telnet program and open the FTP program.

Navigate the /big/dom/xdomain/john/mail1 directory.

Copy the editor file at the /big/dom/xdomain/john/mail1 location on the hard disk of a local computer.

Open the editor file using the vi editor to display the following parameters:

|/usr/local/bin/ezmlm/ezmlm-reject
|/usr/local/bin/ezmlm/ezmlm-send '/big/dom/xdomain/john/mail1'
|/usr/local/bin/ezmlm/ezmlm-warn '/big/dom/xdomain/john/mail1' || exit 0

Append the following parameters in the editor file to add the From header to this file.

|egrep "^From:.*xy@abc.com" || (echo "This is an outgoing list only"; exit 100)

This parameter adds the From header to the editor file.

Save the modified editor file in the /big/dom/xdomain/john/mail1 directory.

After modifying the editor file, the From header added in the editor file sends an e-mail message to the e-mail address specified in the From header. If the e-mail address specified in the From header does not exist on a server, the message is returned to the sender.

You can also add or remove qmail users, or prohibit the external files, which are attached to the e-mail message. When you create a mailing list, the text directory is automatically created. The files in the text directory contain text of the messages sent to and from a mailing list. You can edit the text in the files of the text directory to change the settings of the mailing list, such as the From header or the theme of the mailing list.

You can use the following commands to add or remove the qmail users from a mailing list:

ezmlm-sub: Subscribes an e-mail address to a mailing list. For example, the command to subscribe john@abc.net to the mail1 mailing list is:

ezmlm-sub mail1 john@abc.net

ezmlm-unsub: Unsubscribes an e-mail address from a mailing list. For example, the command to unsubscribe john@abc.net from the mail1 mailing list is:

ezmlm-unsub mail1 john@abc.net

ezmlm-list: Displays a list of qmail users subscribed to a mailing list. For example, the command to display a list of qmail users subscribed to the mail1 mailing list is:

ezmlm-list mail1

Using the EZMLM WEB Tool

EZMLM can also use a Web-based tool, EZMLM WEB, to create and maintain the mailing list.

The EZMLM WEB tool helps to create, edit, and delete the mailing lists using a Web browser. The features of EZMLM WEB tool are:

Provides support to the command line options on the Web browser.

Provides support to run this tool on a platform that can execute EZMLM and Perl, which is a type of programming language.

Provides support to run EZMLM on the Internet Explorer 5.0, Netscape 4.7, and Linux 2.8.3.

Provides access to more than one mailing list by a single end user.

These features help to maintain a list of e-mail addresses in a mailing list. For example, to create a new mailing list using EZMLM WEB:

Open the EZMLM in the Internet Explorer to display the E Z Mailing List Manager screen, as shown in Figure 9-5:

Click To expand: This figure shows a list of three different functions that are performed using the EZMLM WEB tool.
Figure 9-5: The E Z Mailing List Manager Screen

Click the Create button on the E Z Mailing List Manager screen to display the Create a New List screen, as shown in Figure 9-6:

Click To expand: This figure shows different List options used to create a mailing list.
Figure 9-6: The Create a New List Screen

Enter the corresponding values in the Sublist, From Address, Digest options, and SQL Database textboxes on the E Z Mailing List Manager screen.

Click the Create List button to create the mailing list, testing.

You can also edit and delete the testing mailing list using the EZMLM WEB tool. To edit the testing mailing list:

Open the EZMLM WEB tool to display the EZ Mailing List Manager screen.

Select the testing mailing list from the e-mail addresses list box on the EZ Mailing List Manager.

Click the Edit button to display the Subscribers to testing screen, as shown in Figure 9-7:

Click To expand: This figure shows different buttons, such as Delete Addresses and Add Addresses. You can add or remove the e-mail addresses from the existing mailing list using these buttons.
Figure 9-7: The Subscribers to testing Screen

Click the Configuration button to display the Edit the List Configuration screen, as shown in Figure 9-8:

Click To expand: This figure shows different List options to edit the configuration of the testing mailing list.
Figure 9-8: The Edit the List Configuration Screen

Click the Update Configuration button to modify the settings of the testing mailing list.

You can delete the entire mailing list, when the e-mail addresses in the mailing list are not required. To delete the mailing list:

Open the EZMLM mailing list manager to display the EZ Mailing List Manager screen.

Select the name of the mailing list from the list box on the EZ Mailing List Manager screen.

Click the Delete button to display the Confirm deletion of testing screen, as shown in Figure 9-9:

Click To expand: This figure shows that a warning is displayed before deleting a mailing list. You can click the No button, if you do not want to delete the mailing list.
Figure 9-9: The Confirm deletion of testing Screen

Click the Yes button to delete the testing mailing list.

Advanced Configuration

You need to configure the advanced settings, such as the settings of POP protocols, to receive the e-mail messages from other computers. The POP protocol helps retrieve an e-mail message from a mail server.

procmail is a Message Delivery Agent (MDA) that accepts e-mail messages from an MTA and delivers the e-mail message to the mailbox of an end user using the POP protocol. You can use procmail to filter the e-mail messages, based on the content of header fields or the message body.

The advanced configuration of qmail includes configuring the server and the client computers using the POP protocols. A server using the POP protocols receives and stores the e-mail messages in the inbox of an e-mail account.

Understanding procmail

procmail helps to sort, delete, forward, and store e-mail messages depending on the message sender, subject, and other characteristics. For example, you can use procmail to direct all the e-mail messages sent by John into a folder called John in your mailbox. You can read these messages using Mail User Agents (MUAs).

You need to create a set of recipes or instructions to be followed by procmail, when you receive an e-mail message. These recipes are present in a file called .procmailrc, which is stored in the home directory. You can create the .procmailrc file using a UNIX-based editor, such as vi and pico. To use procmail with qmail, you need to run the following command at the qmail command line:

| preline procmail

This command integrates procmail with qmail.

procmail accepts the e-mail messages in the mbox format. You can use the preline command to convert the e-mail messages to the mbox format. You can directly send all the e-mail messages to the home directory of an end user by adding the following command to the .qmail file:

|/usr/local/bin/qmail-procmail

Configuring POP

The POP server of qmail, such as qmail-pop3d, is not configured when you install qmail. A qmail-pop3d server contains three modules:

qmail-popup: Accepts the username and password.

checkpassword: Verifies the username and password.

qmail-pop3d: Represents the POP module.

Note 

POP module is a program, which uses the POP protocol and receives the e-mail messages from another computer.

The inetd process of qmail executes the qmail-popup module. In the qmail-popup module, when a connection is made to the POP3 port, the inetd process prompts for the username and password. After the qmail-popup module receives the username and password from the end user, the inetd process invokes the checkpassword package, which verifies the username and password.

Note 

A POP server uses the POP protocol to store the messages of an end user until the messages are read or downloaded.

You need to download and install the checkpassword package to install the qmail-pop3d server. The checkpassword package is the authentication package used by qmail-pop3d to authenticate users with the Unix password file. To install the checkpassword package:

Download the checkpassword package from the following Uniform Resource Locator (URL):

http://cr.yp.to/checkpwd/install.html.

Unpack the checkpassword package in the root directory, using the following commands:

gunzip checkpassword-0.90.tar
tar -xf checkpassword-0.90.tar

Change the root directory to the checkpassword-0.90 directory, to compile the checkpassword package using the following command:

cd checkpassword-0.90
make

Figure 9-10 shows the output of the make command:

Click To expand: This figure shows how the make command is being executed.
Figure 9-10: Output of the make Command

Enter the following command at the command line to install the checkpassword package in the /bin/checkpassword directory:

make setup check

Figure 9-11 shows the output of the make setup check command:

Click To expand: This figure shows the process of executing the make setup check command.
Figure 9-11: Output of the make setup check Command

After verifying the username and password using the checkpassword package, the inetd process invokes the qmail-pop3d module. You also need to install the qmail-pop3d server to configure qmail for receiving messages. To install the qmail-pop3d server:

Create the /qmailpop3d/run file in the /var/qmail/supervise directory. This file contains the following parameters that help run the qmail pop3d server:

#!/bin/sh
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup \
qmail.solutions.com /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir 2>&1

Create the /log /run file in /var/qmail/supervise/ qmailpop3d directory. The /log/run file contains the following parameters that help to create the log files for the qmail pop3d server:

#!/bin/sh
exec /usr/local/bin/setuidgid qmail /usr/local/bin/multilog t \
/var/log/qmail/pop3d

Create the log directory and set the permissions in the run file using the following commands to provide access permissions to the qmail pop3d server:

chmod +t /var/qmail/supervise/qmail-pop3d
mkdir /var/log/qmail/pop3d
chown qmail /var/log/qmail/pop3d
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
ln -s /var/qmail/supervise/qmail-pop3d /service

Open the qmailctl file from the /var/qmail/bin directory in the vi editor, and add the following parameters in the start section of the qmailctl file to start of the qmail pop3d server:

if svok /service/qmail-pop3d;
then
svc -u /service/qmail-pop3d
else
echo qmail-pop3d service not running
fi

Add the following parameters in the stop section of the qmailctl file to stop the qmail pop3d server:

echo "qmail-pop3d"
svc -d /service/qmail-pop3d

Add the following parameters in the stat section of the qmailctl file to create logs of the qmail pop3d server:

svstat /service/qmail-pop3d
svstat /service/qmail-pop3d/log

Add the following parameters in the pause section of the qmailctl file to pause the qmail pop3d server:

echo "Pausing qmail-pop3d"
svc -p /service/qmail-pop3d

Add the following parameters in the cont section of the qmailctl file to resume the qmail pop3d server:

echo "Continuing qmail-pop3d"
svc -c /service/qmail-pop3d

Add the following parameters in the restart section of the qmailctl file to restart the qmail pop3d server:

echo "* Restarting qmail-pop3d."
svc -t /service/qmail-pop3d

POP Clients

POP clients are the computers that use the POP protocols to receive the e-mail messages. The e-mail messages are delivered directly to the client computer by using POP protocol. As a result, deleting the messages from the inbox of the client computer does not delete the message on the server.

The programs used in POP clients are fetchmail and getmail. fetchmail helps to retrieve messages from a POP server and send the messages to the local computer. You can save the following parameters in the fetchmailrc file for a computer with qmail installed on it:

poll qmail.solutions.com proto pop3 nodns
user john with password john123 is dave here
fetchall forcecr

In the above code, fetchmail helps connect to the qmail.solutions.com domain through the POP3 protocol with the username as john and password, john123. After logging on the domain, fetchmail retrieves the messages from the qmail.solutions.com domain, and delivers the messages to dave@localhost.

getmail helps to retrieve messages from one or more e-mail accounts to the inbox of a local computer. The e-mail accounts exist on different mail servers. The features of getmail are:

Helps to access the messages using various protocols, such as POP3.

Retrieves the messages from more than one inboxes and servers of different e-mail accounts.

Supports message filtering, which is a technique that helps to send and receive only selected e-mail messages.

Maintains reliability of e-mail messages, which means that the e-mail messages are not lost or damaged while they are sent and received to and from an e-mail address.

Chapter 10: Spam Filtering with qmail

Spam is a junk e-mail message, which a mail server sends to the e-mail addresses of the subscribers of a mailing list. Spammers are the group of mail servers, which send the spam to a mailing list. You can filter spam on the basis of some criteria, such as the IP address from which you receive the junk e-mail messages, the content of the e-mail message headers, and the content of the e-mail message to prevent receiving the junk e-mail message.

You can apply filters to the e-mail messages in the mailbox, while receiving and delivering the e-mail messages. You can apply filters to an e-mail message at the time of connection between the remote computer and the server, during the Simple Mail Transfer Protocol (SMTP) connection before you receive the e-mail message, during the SMTP connection after you receive the e-mail message, or when you deliver the e-mail message to the recipients.

This chapter describes how to filter spam using the server-level and the client-level filtering options. It also describes the SpamAssassin tool, which helps filter spam from the incoming e-mail messages.

Server-Level Filtering Options

A qmail administrator can use the server-level filtering options, such as rejecting SMTP connections, using SMTP daemon, or using the qmail-smtpd configuration file, to add spam filter in qmail.

Rejecting SMTP Connections at Network Level

The UNIX operating system can block the data that you transfer on the network, on the basis of various criteria, such as host name or IP address. These criteria that you define while installing the operating system are called host-based access controls. The UNIX operating system blocks the data from the host that do not map a valid IP address and rejects the connection to SMTP. To reject the SMTP connection request, you need to append and save the following information in the /etc/hosts.allow file:

# The connection request from Arnold end user is rejected.
ALL: ARNOLD: RFC931 20: deny

Alternatively, you can also use the tcpserver program to reject the SMTP connection request and accept the incoming Transmission Control Protocol (TCP) connection requests.

Listing 10-1 shows the script of the run file:

Listing 10-1: The run File Script

#!/bin/sh
QMAILDUID='id -u qmaild'
NOFILESGID='id -g qmaild'
exec softlimit -m 3000000 \
tcpserver -v -p -x /etc/qmail/tcp.smtp.cdb \
-u $QMAILDUID -g $NOFILESGID 0 smtp \
sh -c 'test -z "$TCPREMOTEHOST" \
&& echo "451 bad reverse DNS" \
|| exec /var/qmail/bin/qmail-smtpd' 2>&1

In the above listing, the tcpserver program removes the TCPREMOTEHOST environment variable, if it is not able to map an IP address to a domain name.

The ucspi-tcp package contains a set of tools that accept or reject the e-mail messages on the basis of different rules. Some of these rules are defined on a local computer and use a single host and other rules are shared with multiple hosts. The rules for filtering the e-mail messages are defined in the smtprules.cdb file at the /var/qmail/rules/ location. The smtprules.cdb file contains the parameters to allow and deny connections on the basis of the host name of the IP address of a host.

For example, Listing 10-2 shows the script of the smtprules.cdb file that defines the parameters to allow or deny a connection with one host to another:

Listing 10-2: Script of the smtprules.cdb File

# allow relay from this host
192.:allow,RELAYCLIENT=""
# allow relay from other hosts on this network
162.16.42.:allow,RELAYCLIENT=""
162.16.15-18.:allow,RELAYCLIENT=""
# reject all connections from spam source
10.10.88.99:deny
# reject connections from badly managed DSL pool
=.xy.net:deny
# otherwise, allow connections but no relay
:allow

In the above listing, the allow, RELAYCLIENT rule allows a connection request made by the hosts and the deny rule denies a connection request made by the hosts.

To filter the spam at the network level, you need to reject a connection request from different hosts. Enter the following parameters in the smtprules.cdb file at the /var/qmail/rules/ location, to reject a connection request from different hosts:

192.18.0.59: deny
192.168.0.20-50.: deny

The above parameters reject the connection request from the single IP address, 192.18.0.59, or from the range of IP addresses, 192.168.0.20-50. You can also specify the name of a host in the smtprules.cdb file. For example, if you need to reject the connection request from the mail.abc.com host or the host name, which ends with xy.net, you can enter the following parameters in the smtprules.cdb file:

=mail.abc.com: deny
=.xy.net: deny

When a tcpserver receives an incoming connection request, the tcpserver searches the IP address or the host name in a sequence. For example, if the IP address of a host is 192.18.0.59 and the name of the host is mail.abc.com, the sequence of the search is:

192.18.0.59
=mail.abc.com
192.18.0.
192.18.
192.
.
=.abc.com
=.com
=

In the above sequence, a single dot specifies search for any IP address and a single equal to sign specifies search for any host name.

Using the qmail-smtpd Configuration File

You can filter spam by using patches for the qmail-smtpd configuration file. When you execute the qmail-smtpd configuration file, the filters can use the message header to filter the e-mail messages. Some filters create a patchin the qmail-queue file while other filters use the existing QMAILQUEUE patch, to run the filter on the incoming e-mail messages. The patches that help qmail to reject the e-mail messages on the basis of e-mail addresses specified in the From header of the e-mail message are:

CHECKATTACH

CHECKSUBJ

CHECKFILE

The CHECKATTACH patch helps to filter the e-mail messages on the basis of the type of file attached to the e-mail messages.

Listing 10-3 shows the content of the script file of the CHECKATTACH patch:

Listing 10-3: Script of the CHECKATTACH Patch

# Start program here.
printmsg () {
echo "The reason your e-mail message is rejected is that you have sent an attachment that can
cause problems."
echo "The attachment you sent is in the violation of the policy of the company because it can
cause problems, such as virus infecting the e-mail messages, increase in the traffic load, or
the deletion of files."
echo "Please disable HTML formatting when you send an e-mail message because Visual Basic Script
Worms/Virus exploits the e-mail message with HTML formatting."
echo "--- The extension to the attachment of a file you sent is $ATTYPE"
}
#
# Check for NOT allowed attachment.
# Here you can specify the extensions of files on the basis of, which you can filter the e-mail
messages.
#
checktype () {
case $ATTYPE in
VBS | VBE | JSE | CSS | WSH | SCT | HTA | VXD | EXE | HTM | DOT | HLP | PAK | DAT | PCX
| PPS | COM | BAT | CMD | AVI | MOV | RAM | OCX | CAB | SHS | CLA | RA | BMP | MPE |
MPG | MP3 | MP4 | WAV | AUD | AU | DLL)
printmsg $ATTYPE
exit 100;;
*)
;;
# The default case
esac
}
#ATTACHTYPE='grep "filename=" - | gawk '{split($NF, results, "."); r=toupper(results[2]); print
r}' | cut -c -3`
####Below does not work if more than 2 fields in name=
#ATTACHTYPE=`grep "name=" - | gawk '{split($NF, results, "."); r=toupper(results[3]); print r}'
| cut -c -3'
#### End of ver. 0.3
exit 0

The CHECKSUBJ patch helps to filter the e-mail messages on the basis of the subject line of the e-mail messages.

Listing 10-4 shows the content of script file of the CHECKSUBJ patch:

Listing 10-4: Script of the CHECKSUBJ Patch

printsubj () {
 echo "Your E-Mail message is rejected because it contained a Subject like: $SUBJECTLINE."
 echo "The mail server does not accept the E-Mail messages."
}
checksubject () {
    case $SUBJECTLINE in
    bomb|xyz|abc*)
    printsubj $SUBJECTLINE
    exit 100;;
*)
;;
esac
}
SUBJECT=`(grep "Subject: " | head -n 1 | awk -F: '{print $2}')`
for SUBJECTLINE in $SUBJECT
do
checksubject $SUBJECTLINE
done
exit 0

The CHECKFILE patch helps to filter the e-mail messages on the basis of name of the file attached to the e-mail messages.

Listing 10-5 shows the content of script file of the CHECKFILE patch:

Listing 10-5: Script of the CHECKFILE Patch

# Start program here.
printmsg () {
        echo "The reason your email is rejected is that you sent an attachment that can cause
        problems."
        echo "The attachment you sent is in violation of the policy of the company  because it
        can cause problems, such as virus infecting the e-mail messages, or increase traffic
        load."
        echo "Please disable HTML formatting when sending e-mail message because Visual Basic
        Script Worms/Virus exploits the e-mail message with HTML formatting."
        echo "--- Attachment $ATTFILE is rejected"
    }
    #
    # Check for NOT allowed attachment.
    # Here you can include more filenames that you want.
    #
    checkfile () {
        case $ATTFILE in
        abc.EXE )
        printmsg $ATTFILE
        exit 100;;
    *)
    ;;
    esac
}
## This allows filtering of individual Attachments identified by the name.
## Specify the attachment filename in UPPERCASE
ATTACHFILE=`grep "name=" - |  cut -d'"' -f2 | tr '[a-z]' '[A-Z]'`
for ATTFILE in $ATTACHFILE
do
checkfile $ATTFILE
done
exit 0

Using SMTP Daemon to Filter Known Spammers

SMTP daemon is a small program, which uses SMTP to run a process in the background of an application. SMTP daemon contains different checks, which filter the spam. The three checks in SMTP daemon are MAIL FROM rejection, RCPT TO rejection, and Windows EXE virus rejection.

The MAIL FROM rejection check contains the parameters, such as the e-mail addresses and domains listed in the badmailfrom control file. qmail rejects the e-mail messages that you receive from the e-mail addresses and domains listed in the badmailfrom control file.

The RCPT TO rejection check contains the parameters, such as the e-mail addresses and domains that are listed in the badrcptto patch. qmail does not deliver the e-mail messages to the e-mail addresses and the domains that are listed in the badrcptto patch.

The Windows EXE virus rejection check rejects the e-mail messages that contain a file, with .EXE extension, attached to the e-mail message. There are various other filtering checks for the SMTP daemon that searches for a Domain Name System (DNS) on the domain of each MAIL FROM address and rejects the e-mail messages, which are sent to the domains specified in the MAIL FROM address.

To filter a spam, you need to run a shell script that calls a filtering program. When you receive an e-mail message, you need to filter the e-mail message and add the e-mail message in a queue for delivery. For example, you can create the /var/qmail/bin/smtp-spa executable file in the vi editor to filter the e-mail message and add the e-mail messages to the qmail-queue module. The code to create the /var/qmail/bin/smtp-spa file is:

#!/bin/sh
/usr/local/bin/spamassassin | /var/qmail/bin/qmail-queue

In the above code, spamassassin is a spam filter, which filters the e-mail messages for the spams and qmail-queue is the file, which stores the queue of e-mail messages. When qmail executes the /var/qmail/bin/smtp-spa file, the SpamAssassin filter program filters the e-mail messages and sends the filtered e-mail messages to the qmail-queue file, to store the e-mail messages in a queue for delivery.

Client-Level Filtering Options

qmail provides certain client-level filtering options, such as junkmail filtering, Bayesian filtering, and various third party filtering tools. You can also use tools, such as SpamAssassin to filter the e-mail messages containing spam and viruses.

Using Mail User Agent (MUA) Junkmail Filtering

An MUA can filter viruses using the anti-virus software. It can also filter spam using various techniques, such as Bayesian filtering. It can also create white lists and black lists that help in filtering the e-mail messages. The white list contains a list of e-mail addresses from which you can receive the e-mail messages and the black list contains the e-mail addresses from which you cannot receive the e-mail messages. These techniques check for the e-mail addresses, header of the e-mail message, or the content of the e-mail message to filter the e-mail messages.

Using Bayesian Filtering

Bayesian filtering technique recognizes the spam content in the e-mail messages. This technique is based on the principle that most events are dependent on each other and that the probability of an event to occur is analyzed from the previous occurrences of that event. For example, if a text occurs repeatedly in a spam but not in other mails, then the text is used as a reference for a spam. The characteristics of an e-mail message, which a Bayesian spam filter consider for filtering are:

Body text

Headers

Html code

Phrases

There are various filters, such as Bogofilter, which uses the Bayesian filtering technique. Bogofilter is an e-mail message filter that classifies an e-mail message as a spam by analyzing the header or the content of the e-mail message.

The advantages of the Bayesian filtering technique are:

Considers the entire e-mail message to recognize the keywords in the e-mail message that identify the spam. It also recognizes the text in an e-mail message, which denotes that the e-mail message is not a spam.

Adapts new spam techniques to filter the spam. The Bayesian technique adapts itself to the new spams that spammers add to the e-mail messages. For example, if the spam, cost, is defined in a spam filter and the spammer converts the cost spam to c-o-s-t, the Bayesian technique recognizes the c-o-s-t spam also.

Filters spam that contains keywords in different languages. The keywords for a spam that are listed in a Bayesian filter include the text commonly used in different parts of the world.

Using Third-Party Filtering Tools

There are various filtering tools that help in rejecting the incoming e-mail messages with spam, before you deliver the e-mail message to the recipient. These filtering tools are:

The Mail Abuse Prevention System (MAPS) Realtime Blackhole List (RBL): Lists the hosts and networks, from which the spam is originated or relayed. It also lists the hosts that provide the spam support services to other hosts or the hosts that provide spam support service to themselves.

The MAPS Relay Spam Stopper (RSS) list: Lists the mail servers that transfer the spam from one mail server to another. The spammers do not run these mail servers. The company, which is unable to configure the mail servers, runs these mail servers. As a result, the server permits an unauthorized end user to send e-mail messages from that server.

The MAPS Dialup User List (DUL): Lists the dialup IP addresses. A Web site that uses DUL rejects the e-mail messages that are received from the IP addresses of the computers, listed in DUL.

The Open Relay Database (ORDB): Lists the open-relay SMTP servers. The ORDB lists all the open relay servers whether or not these servers send spam.

The Spamhaus Block List (SBL): Lists the IP addresses of the verified spammers.

Introducing SpamAssassin

SpamAssassin is an e-mail message filtering tool that identifies the spam based on the text of the e-mail message and Internet-based real time blacklist. This tool identifies the spam in the headers and body text of the e-mail messages. When SpamAssassin identifies an e-mail message as a spam, it adds a tag of spam to the e-mail message such that the end users can move the spam e-mail messages to a separate folder or delete these e-mail messages. The SpamAssassin tool performs the following functions to identify spam:

Checks the header and the body text of an e-mail message for the text categorized as spam.

Checks the header of an email message for consistency and adherence to the Internet standards, such as format of a date.

Checks for a valid IP address of the computer that sends the e-mail messages.

Blacklists specific IP addresses, host names, and domain names.

Installing and Configuring SpamAssassin

You can use the SpamAssassin tool to filter spam at Mail Transfer Agent (MTA), Mail Delivery Agent (MDA), and Post Office Protocol (POP) proxy. You need to install the SpamAssassin tool on the Linux operating system to filter the e-mail messages containing spam and viruses. To install SpamAssassin on Linux operating system:

Download the Mail-SpamAssassin-2.60.tar.gz file from http://old.spamassassin.org/released/.

Enter the following command at the command line to unzip the Mail-SpamAssassin-2.60.tar.gz file:

# gunzip -c Mail-SpamAssassin-2.60.tar.gz | tar xf -

Enter the following command at the command line to change from the root directory to the Mail-SpamAssassin-2.60 directory:

# cd Mail-SpamAssassin-2.60

Enter the perl Makefile.PL command at the command line to create a perl script. The output of this command is:

# perl Makefile.PL
What email address or URL should be used in the suspected-spam report
text for users who want more information on your filter installation?
(In particular, ISPs should change this to a local Postmaster contact)
default text: [the administrator of that system]

Enter the postmaster@smartdevelopers.com parameter at the command line and press Enter to continue and display the following output at the command line:

postmaster@smartdevelopers.com
Checking if your kit is complete...
Looks good
Warning: I could not locate your pod2man program. Please make sure,
your pod2man program is in your PATH before you execute 'make'
Writing Makefile for Mail::SpamAssassin
Makefile written by ExtUtils::MakeMaker 6.03

Enter the following command at the command line to compile the MakeFile:

# make

Enter the following command at the command line to install the Mail-SpamAssassin-2.60 tool:

# make install

After installing the Mail-SpamAssassin-2.60 tool, you need to configure the Mail-SpamAssassin-2.60 tool using the local.cf file, to enable spam filtering. The local.cf configuration file is located at the /etc/mail/spamassassin location.

Listing 10-6 shows the default content of the local.cf file:

Listing 10-6: The Default local.cf File

# These values can be overridden by editing /.spamassassin/user_prefs.cf
# (see spamassassin(1) for details)
# These should be safe assumptions and allow for simple visual sifting
# without risking lost emails.
# How high a score is considered spam?
required_hits 5
# Should we tag the subject of spam messages?
rewrite_subject 1
subject_tag [SPAM]
# How should spam reports be inserted into the message?
report_safe 0
# By default, SpamAssassin will run RBL checks. If your ISP already
# does this, set this to 1.
skip_rbl_checks 0

In the above listing, requied_hits, rewrite_subject, and report_safe hare the configuration directives that are followed by directive values. The value of the required_hits directive specifies the number of times an e-mail message is received before being categorized as smap. The rewrite_subject stores a Boolean value to rewrite the subject of an e-mail message. The report_safe directive stores a Boolean value, which specifies whether or not the spam report is included in the e-mail message.

You can also test the SpamAssassin tool after installing and configuring the SpamAssassin tool. Enter the following command at the command line to test the SpamAssassin tool:

# spamassassin  --test-mode < /1/usr/share/doc/spamassassin-2.60/sample-nonspam.txt

The output of the above command is:

Return-Path: <tbtf-approval@world.std.com>
Delivered-To: foo@foo.com
Received: from europe.std.com (europe.std.com [192.168.0.50])
by mail.netnoteinc.com (Postfix) with ESMTP id 392E1114061
for <foo@foo.com>; Wed, 15 Dec 2004 14:34:46 +0000 (Eire)
Received: (from daemon@localhost)
by europe.std.com (8.9.3/8.9.3) id RAA09630
for tbtf-outgoing; Wed, 15 Dec 2004 12:31:18 -0400 (EDT)
Received: from sgi04-e.std.com (sgi04-e.std.com [199.172.62.134])
by europe.std.com (8.9.3/8.9.3) with ESMTP id RAA08749
for <tbtf@facteur.std.com>; Wed, 15 Dec 2004 15:24:31 -0400 (EDT)
....
....

This output specifies that the installed and configured SpamAssassin has been executing successfully.

Integrating SpamAssassin with qmail

You need to integrate the SpamAssassin tool with qmail-based mail servers to check for spammed e-mail messages that are received and delivered through qmail.

There are various components of qmail, such as qmail-smtpd, qmail-queue, qmail-send, and qmail-lspawn, which help receiving the e-mail messages from Internet. You can use these components of qmail to check for incoming spammed e-mail messages using the SpamAssassin tool. qmail provides the QMAILQUEUE patch, which helps check the e-mail messages when these e-mail messages are received, before the final delivery. When you apply the QMAILQUEUE patch, the qmail-smtpd daemon verifies whether the QMAILQUEUE environment variable is set or not. The qmail-smtpd daemon sends the e-mail message to another program, such as SpamAssassin, which then passes the e-mail message to the qmail-queue daemon.

Figure 10-1 shows how the QMAILQUEUE patch is applied to divert the incoming e-mail messages to SpamAssassin:

Figure 10-1: Applying The QMAILQUEUE Patch

Building a Spam-Checking Gateway Using SpamAssassin

You can also build a spam-checking gateway, such as qmail-scanner using the SpamAssassin tool. The qmail-scanner enables the qmail mail server to scan the e-mail messages for spam and virus. You can integrate qmail-scanner with SpamAssassin to provide anti-spam tags for e-mail messages. The qmail-scanner checks for the viruses in e-mail messages with the help of multiple external virus-scanner. The internal scanner of qmail-scanner can also block the e-mail messages based on the type of file that is attached to an e-mail message.

To install qmail-scanner:

Download the qmail-scanner zip file from http://prdownloads.sourceforge.net/qmail-scanner/qmail-scanner-1.24.tgz?download.

Enter the following command at the command line to unzip the qmail-scanner-1.24.tgz file:

# gunzip qmail-scanner-1.24.tgz

Enter the following command at the command line to change from the root directory to the qmail-scanner-1.24 directory:

# cd qmail-scanner-1.24

Enter the following command at the command line to start the installation of qmail-scanner:

# ./configure -install

The output of this command is:

Building qmail-Scanner 1.24...
This script will search your system for the virus scanners it knows
about, and will ensure that all external programs
qmail-scanner-queue.pl uses are explicitly pathed for performance
reasons.
It will then generate qmail-scanner-queue.pl - it is up to you to install it
correctly.
Continue? ([Y]/N)

Enter Y for yes at the command line to continue and display the following output at the command line:

/usr/bin/uudecode works as expected on system...
The following binaries and scanners were found on your system:
mimeunpacker=/usr/local/bin/reformime
uudecode=/usr/bin/uudecode
unzip=/usr/bin/unzip
Content/Virus Scanners installed on your System
fprot=/usr/local/bin/f-prot
fast_spamassassin=/usr/local/bin/spamc
qmail-Scanner details.
log-details=0
fix-mime=2
ignore-eol-check=0
debug=1
notify=psender,nmlvadm
redundant-scanning=no
virus-admin=postmaster@example.com
local-domains='example.com'
silent-
viruses='klez','bugbear','hybris','yaha','braid','nimda','tanatos','sobig','winevar','pal
yh','fizzer','gibe','cailont','lovelorn','swen','dumaru','sober','hawawi','holar-
i','mimail','poffer','bagle','worm.galil','mydoom','worm.sco','tanx','novarg','@mm'
scanners="fprot_scanner","fast_spamassassin"
If that looks correct, I will now generate qmail-scanner-queue.pl
for your system...
Continue? ([Y]/N)

Enter Y for yes at the command line to continue and display the following output:

Finished. Please read README(.html) and then go over the script to
check paths/etc, and then install as you see fit.
Remember to copy quarantine-attachments.txt to /var/spool/qmailscan and then
run "qmail-scanner-queue.pl -g" to generate DB version.
****** FINAL TEST ******
Please log into an unpriviledged account and run
/var/qmail/bin/qmail-scanner-queue.pl -g
If you see the error "Can't do setuid", or "Permission denied", then
refer to the FAQ.
(e.g.  "setuidgid qmaild /var/qmail/bin/qmail-scanner-queue.pl -g")
That's it! To report success:
% (echo 'First M. Last'; cat SYSDEF)|mail xyz@abc.com
Replace First M. Last with your name

You need to edit the /etc/tcp.smtp file and initialize qmail scanner to enable its functioning. To edit the /etc/tcp.smtp file and initialize the qmail-scanner:

Enter the following parameters in the /etc/tcp.smtp file, using the vi editor to enable qmail-scanner:

192.168.:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
10.:allow,RELAYCLIENT="",QS_SPAMASSASSIN="on",QMAILQUEUE="/var/qmail/bin/qmail-
scanner-queue.pl"
:allow,QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"

The above parameters enable the e-mail messages to pass through the qmail-scanner before being delivered to the mailbox.

Enter the following command at the command line to initialize qmail-scanner:

# /var/qmail/bin/qmail-scanner-queue.pl 'z
# /var/qmail/bin/qmail-scanner-queue.pl 'g

The output of this command is

perlscanner: generate new DB file from /var/spool/qmailscan/quarantine-attachments.txt
perlscanner: total of 9 entries.

Enter the following command at the command line to change to the contrib directory:

# cd contrib.

The contrib. directory stores the test_installation file that helps to test the installation of qmail-scanner.

Enter the following command at the command line to test the functioning of qmail-scanner:

# QMAILQUEUE="/var/qmai/bin/qmail-scanner-queue.pl" ./test_installation.sh -doit

The output of this command is:

Sending standard test message - no viruses...
done!
Sending eicar test virus - should be caught by perlscanner module...
done!
Sending eicar test virus with altered filename - should only be caught by commercial
anti-virus modules (if you have any)...
Sending bad spam message for anti-spam testing - In case you are using SpamAssassin...
Done!
Finished test. Now go and check Email for root

This output specifies that the qmail-scanner is working.

Check the inbox of the root user for the e-mail messages received. The root user receives the following header for non-spam message:

Received: from  by smartdevelopers.com by uid 123 with qmail-scanner-1.24
 (f-prot: 3.11/. spamassassin: 2.60.  Clear:RC:1(127.0.0.1):SA:0(0.0/5.0):.
 Processed in 5.577981 secs); 15 Dec 2004 03:03:28 '0000

The root user receives the following header for a spam message:

Received: from  by smartdevelopers.com by uid 123 with qmail-scanner-1.24
(f-prot: 3.11/. spamassassin: 2.60.  Clear:RC:1(127.0.0.1):SA:1(16.7/5.0):.
Processed in 5.129358 secs); 15 Dec 2004 03:03:40 -0000
X-Spam-Status: Yes, hits=16.7 required=5.0
X-Spam-Level: ++++++++++++++++

Appendix A: Frequently Asked Questions

This appendix provides answers to frequently asked questions about Exchange Server and qmail.

Questions

A-1: How do you disable qmail to perform reverse Domain Name System (DNS) lookups on Simple Mail Transfer Protocol (SMTP) connections?

A-2: How do you change the pop-greeting message of the qmail server?

A-3: How do you set the time for e-mail messages to be kept in the qmail queue?

A-4: How do you set the limit for the maximum number of bytes stored in the e-mail messages?

A-5: Which command will you use to list the functions that can be performed by the qmailctl script file?

A-6: What is the function of the /var/qmail/control/badmailfrom file in qmail?

A-7: How can you change the bounce message, mailer-daemon@yourdomain.com, received from qmail server?

A-8: What are the various operating systems supported by qmail.

A-9: What should you do if images are not displayed when you start the qmailadmin tool?

A-10: Can you run Vpopmail at the command line instead of the qmailadmin tool?

A-11: What is the function of host masquerading?

A-12: How do you change your e-mail address from yourAccount@solutions.com to myAccount@solutions.com?

A-13: What are the various packages that should be installed on a computer before installing qmail?

A-14: What software packages are not required for installation of qmail?

A-15: What are the various outbound ports?

A-16: What are the various inbound ports?

A-21: How do you fix the error, Cannot find either the gdbm or the db library, which occurs at the time of running the IMAP configuration script?

A-22: How do you start Courier IMAP at the time of starting the qmail server?

A-23: Can you transfer the entire Vpopmail directory structure, containing domains, users, and passwords, from one qmail server to another?

A-24: How do you remove the error, configure: error: No vpopmail etc/lib_deps file, which occurs when you install vpopmail?

A-25: What are the various features of qmail?

A-26: How is qmail compatible with sendmail?

A-27: What is the use of POP3 protocol?

A-28: What are the various utilities in qmail used to manage mailboxes?

A-29: What are the two types of mailstores in qmail and what is the difference between them?

A-30: How do you get spam even when it is not addressed to you?

A-31: What are the minimum hardware requirements to install Exchange Server 2000?

A-32: How do you connect to an Lightweight Directory Access Protocol (LDAP) server, such as Microsoft Exchange Server?

A-33: What Transmission Control Protocol (TCP) ports does Microsoft Exchange Server use?

A-34: What is the main difference between IMAP and POP?

A-35: What are recipient objects in Exchange Server?

A-36: Can you install Outlook 2000 and Outlook 2002 on the same computer?

A-37: How do you ensure whether or not an end user receives an e-mail notification while you create an appointment for a meeting?

A-38: How do you delete a scheduled meeting for all the attendees?

Answers

A-1: How do you disable qmail to perform reverse Domain Name System (DNS) lookups on Simple Mail Transfer Protocol (SMTP) connections?

Answer: You need to add the -H option to the tcpserver call in the run script file of the qmail-smtpd service to disable qmail to perform reverse DNS lookups on SMTP connections. The run script file is stored in the /var/qmail/supervise/qmail-smtpd/ directory. The entry of the run script file that you need to edit is:

/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD"

You need to edit the above entry of the run script file by adding the -H option after the -R option, as shown in the following code:

/usr/local/bin/tcpserver -v -R -H -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD"

A-2: How do you change the pop-greeting message of the qmail server?

Answer: You need to edit the /usr/local/src/netqmail-1.05/netqmail-1.05/qmail-popup.c file by adding the message that you want to set for the pop-greeting message of the qmail server. After editing the qmail-popup.c file, you need to recompile qmail using the following command:

make setup check

A-3: How do you set the time for e-mail messages to be kept in the qmail queue?

Answer: The /var/qmail/control/queuelifetime file helps you to set the time for e-mail messages to be stored in the qmail queue. You need to specify the time in the queuelifetime file in seconds. For example, you need to specify 3600 in the queuelifetime file to represent 3600 seconds for one hour, 86400 seconds for one day, or 604800 seconds for one week.

A-4: How do you set the limit for the maximum number of bytes stored in the e-mail messages?

Answer: The /var/qmail/control/databytes file is used to set the limit for the maximum number of bytes that can be stored for the e-mail messages. The default limit for the number of e-mail messages that is unlimited, which is represented by 0. You need to specify the e-mail message size in the databytes file in bytes. For example, to specify the message size to 20 Mega Bytes (MB), you need to specify 20971520 in the databytes file.

A-5: Which command will you use to list the functions that can be performed by the qmailctl script file?

Answer: You can display various functions of the qmailctl script file using the qmailctl help command.

Figure A-1 shows the output of the qmaictl help command:

Click To expand: This figure shows the various functions, such as stop, start, pause, and stat, of qmailctl.
Figure A-1: The Output of the qmailctl help Command

A-6: What is the function of the /var/qmail/control/badmailfrom file in qmail?

Answer: The /var/qmail/control/badmailfrom file is used to block an individual e-mail address or an entire domain from sending e-mail messages to the qmail server. The code to block an individual e-mail address and entire domain from sending e-mail messages to the qmail server is:

abc@domain1.com
@domain2.com

In the above code, abc@domain1.com indicates that the e-mail message arriving from the abc@domain1.com address are blocked, and @domain2.com indicates that e-mail messages arriving from the domain, @domain2.com, are blocked.

A-7: How can you change the bounce message, mailer-daemon@yourdomain.com, received from qmail server?

Answer: You can change the bounce message of the qmail server using two files, /var/qmail/control/defaultdomain and /var/qmail/control/bouncefrom. The defaultdomain file contains the name of your domain and the bouncefrom file contains the mail user name attached with your domain name. For example, if you change the content of the bouncefrom file to bounce, then the bounce message, bounce@yourdomain, is displayed.

A-8: What are the various operating systems supported by qmail.

Answer: qmail supports all UNIX variants, such as Advanced Interactive eXecutive (AIX), Berkeley Software Distribution/Operating System (BSD/OS), FreeBSD, Hewlett Packard for UNIX (HP/UX), Irix, Linux, NetBSD, OpenBSD, Open Source Foundation (OSF/1), SunOS, and Solaris.

A-9: What should you do if images are not displayed when you start the qmailadmin tool?

Answer: The images of the qmailadmin tool might be copied to the wrong directory at the time of installing the qmailadmin tool. You need to reinstall the qmailadmin tool and configure the tool by specifying the option, as shown in the following code:

./configure -enable-cgibindir=/var/www/cgi-bin -enable-htmldir=/var/www/html

A-10: Can you run Vpopmail at the command line instead of the qmailadmin tool?

Answer: You can run Vpopmail using various command line utilities stored in the /home/vpopmail/bin or /usr/home/vpopmail/bin directory. You can create and delete users and domains using these command line utilities.

A-11: What is the function of host masquerading?

Answer: Host masquerading is used to secure a network by hiding the name of the host using the defaulthost configuration file of qmail. For example, the host name of a remote host is qmail.solutions.com. You want to change the content of the From section of the e-mail message from james@qmail.solutions.com to james@solutions.com, when an end user, James, sends an e-mail message. You can use the following code to hide the full domain name:

echo solutions.com > /var/qmail/control/defaulthost

A-12: How do you change your e-mail address from yourAccount@solutions.com to myAccount@solutions.com?

Answer: You need to set the values for the environment variables, MAILHOST=solutions.com and MAILUSER=myAccount in the qmail environment. You also need to set the environment variable, QMAILINJECT=f to the qmail environment to override the value of the From section specified by the qmail Mail User Agent (MUA).

A-13: What are the various packages that should be installed on a computer before installing qmail?

Answer: The packages that should be installed on a computer before installing qmail are:

Apache Web server 1.3.x or 2.x

PHP 4.0.6 or higher, which supports Internet Message Access Protocol (IMAP) and MySQL

Perl 5.0 or higher

GNU's Not Unix (GNU) C Compiler (GCC)

MySQL 3.x or higher

OpenSSL 0.9.5a or higher

OpenSSL-devel

wget

patch and patchutils

A-14: What software packages are not required for installation of qmail?

Answer: The software packages that are not required for installation of qmail are:

Postfix

Post Office Protocol (POP) service

SMTP service

A-15: What are the various outbound ports?

Answer: The various outbound ports are:

SMTP-25

POP service-110

IMAP-143

Spamassassin-783

IMAPS-993

A-16: What are the various inbound ports?

Answer: The various inbound ports are:

SMTP-25

HyperText Transfer Protocol (HTTP)-80

POP service-110

IMAP-143

HyperText Transfer Protocol Secure (HTTPS)-443

Spamassassin-783

IMAPS-993

A-21: How do you fix the error, Cannot find either the gdbm or the db library, which occurs at the time of running the IMAP configuration script?

Answer: You need to ensure that the gdbm and gdbm-devel packages are installed on your computer. You can download the gdbm and gdbm-devel Redhat Package Managers (RPMs) from the Web site, http://rpmseek.com/rpm-pl/gdbm-devel.html?hl=com&cbd=0:G:0::61.

A-22: How do you start Courier IMAP at the time of starting the qmail server?

Answer: You need to edit the /etc/rc.local file by adding the following command to start IMAP for running Courier IMAP at the time of starting a server:

/etc/rc.d/init.d/imap start
/etc/rc.d/init.d/imaps start

The above code starts the two services, IMAP and IMAP Secure Socket Layer (SSL).

A-23: Can you transfer the entire Vpopmail directory structure, containing domains, users, and passwords, from one qmail server to another?

Answer: Yes, you can transfer the entire Vpopmail directory structure containing domains, users, and passwords from one qmail server to another. You need to ensure that the permissions and ownership settings of the Vpopmail directory structure on the second qmail server are same as on the first qmail server. You need to assign the same User Identity (UID) and Group Identity (GID) to the vpopmail user and group accounts on the second server as assigned to the first server.

A-24: How do you remove the error, configure: error: No vpopmail etc/lib_deps file, which occurs when you install vpopmail?

Answer: The error, configure: error: No vpopmail etc/lib_deps file, occurs when you install vpopmail on the computer on which it is already installed. You need to remove the /home/vpopmail directory of the previous installation of vpopmail and then install vpopmail.

A-25: What are the various features of qmail?

Answer: The various features of qmail are:

Provides security

Provides fast access

Provides reliability

Uses low memory

Enables the end user to create mailing lists

Supports multiple host using virtual host

Supports the maildir format

A-26: How is qmail compatible with sendmail?

Answer: qmail supports various files, such as .forward, /etc/aliases, binmail deliveries, /usr/sbin/sendmail interface for mail injection, and /etc/passwd, which are supported by sendmail.

A-27: What is the use of POP3 protocol?

Answer: POP3 is a client/server protocol for receiving e-mail messages and storing them in your mail server.

A-28: What are the various utilities in qmail used to manage mailboxes?

Answer: The various utilities to manage mailboxes in qmail are:

bouncesaying: Accepts an error message and an optional command to be run as the arguments.

condredirect: Accepts two parameters, an e-mail address and a command to be run on the specified e-mail address.

datemail: Inserts a Date header field in the local time zone in an e-mail message.

elq: Allows to use maildir format with elm, which does not support maildir mailboxes.

forward: Reads a message and forwards a copy of the message to the specified e-mail addresses.

A-29: What are the two types of mailstores in qmail, and what is the difference between them?

Answer: Mailstores are divided into two categories, transparent and opaque. A transparent mailstore can be directly accessed by an MUA whereas an opaque mailstore requires a network protocol to access the mailstore.

A-30: How do you get spam even when it is not addressed to you?

Answer: To receive an e-mail message, it is not necessary that your e-mail address should be specified in the To, CC, and BCC field of an e-mail message. The envelope recipient determines the actual recipient of an e-mail message. The envelope recipient is determined when the mail client interacts with the mail server through SMTP. An envelope recipient is the same as that mentioned in the To field of an e-mail message. The end users, who send spam to the mail server, use modified mail clients. These mail clients specify the recipient and the envelope recipient in the To field of the e-mail message.

A-31: What are the minimum hardware requirements to install Exchange Server 2000?

Answer: You need minimum 1.25 times of RAM for the disk space used to install Exchange Server. If the disk space used under Exchange Server is 512 MB, then the space needed for Exchange Server is 256 MB of RAM.

A-32: How do you connect to a Lightweight Directory Access Protocol (LDAP) server, such as Microsoft Exchange Server?

Answer: You can connect to an LDAP server, such as Microsoft Exchange Server, using the LDAP connector for Microsoft Exchange Server.

A-33: What Transmission Control Protocol (TCP) ports does Microsoft Exchange Server use?

Answer: The various TCP ports used by Microsoft Exchange Server are:

Reference Q176466

TCP 143/993 - IMAP4/IMAP4TLS

TCP 135 - RPC Portmapper.

TCP 80/443 - HTTP/HTTPS

TCP 110/995 - POP3/POP3TLS

TCP 25 - SMTP

TCP 119 - NNTP

TCP 389/636 - LDAP/LDAPTLS

A-34: What is the main difference between IMAP and POP?

Answer: IMAP helps access e-mail messages from folders stored in your mailbox and public folders, and enables you to view the e-mail messages without downloading them. Whereas, with POP you need to download the e-mail messages to your local computer to view them.

A-35: What are recipient objects in Exchange Server?

Answer: Recipient objects are references of the resources that can receive e-mail messages through Exchange Server, and are stored in Active Directory. These resources can be a mailbox, a public folder, or a newsgroup on the Internet.

A-36: Can you install Outlook 2000 and Outlook 2002 on the same computer?

Answer: Microsoft recommends that you should not install the Outlook 2000 and Outlook 2002 packages on the same computer because their services may conflict with each other.

A-37: How do you ensure whether or not an end user receives an e-mail notification while you create an appointment for a meeting?

Answer: E-mail notifications are either sent to all the members of the meeting or to none. By default, all the members of the meeting receive the e-mail notification. You need to click the Cancel Invitation button, if you do not want to send an e-mail notification to any of the member. This will create an appointment for the meeting in the calendars of all members but will not send a notification to the members for whom you have cancelled the e-mail notification.

A-38: How do you delete a scheduled meeting for all the attendees?

Answer: You can delete a scheduled meeting by removing it from your own calendar. However, you can send an e-mail notification to all the attendees indicating the cancellation of the scheduled meeting. To cancel a meeting:

Select the scheduled meeting that you want to cancel from the Calendar page. The Meeting - Appointment window appears, as shown in Figure A-2:

Click To expand: This figure shows the details of a meeting containing the purpose and location for the appointment.
Figure A-2: The Meeting - Appointment Window

Select Cancel Meeting from the Action menu, which prompts you to select one of the following two messages:

Send a cancellation to all attendees and then delete the meeting.

Delete the meeting without sending a cancellation.

Appendix B: Troubleshooting qmail

Troubleshooting qmail involves locating and fixing errors in qmail. The errors in qmail may occur due to various problems, such as bad connection in the network and mail clients and servers not able to send or receive e-mail messages. You can use various methods, such as process monitoring, logs, message headers, and testing to troubleshoot qmail.

This appendix describes different types of problems in qmail and the methods used to troubleshoot the errors that occur due to these problems in qmail.

Fixing Common Problems

You can resolve some of the common qmail problems, such as e-mail message not delivered or e-mail message not retrieved, by using the methods, such as checking the qmail daemons or qmail error logs.

qmail Not Running

When the qmail mail server does not run, you need to check the errors in the configuration files of qmail. You need to create these configuration files when you install qmail. The activities of qmail are logged to the qmail logs, which are created at the /var/log/qmail location. There are three types of logging in qmail that correspond to the 3 categories of qmal modules, which are qmail-smtpd, qmail-send, and qmail-pop3d. There are run and log/run script files for all these three qmail modules, which are located at the following locations:

/var/qmail/supervise/qmail-smtpd/run & /var/qmail/supervise/qmail-smtpd/log/run
/var/qmail/supervise/qmail-pop3d/run & /var/qmail/supervise/qmail-pop3d/log/run
/var/qmail/supervise/qmail-send/run & /var/qmail/supervise/qmail-send/log/run

You can check the configuration of the run and log/run script files to locate the error in the execution of qmail. Enter the following command at the command line to display a list of executing processes:

# ps -aux

The above command displays the list of executing processes. The readproctitle service errors process display the following message, if qmail is running correctly:

root 1291 0.0 0.0 1332 252 ? S Jul06 0:00 readproctitle service errors: .......................................

The important part here is the "...................................". This means that there are no errors being detected.

The readproctitle service errors process displays the following message if qmail is not running:

root 1291 0.0 0.0 1332 252 ? S Jul06 0:00 readproctitle service errors: Mutlilog cannot write
blah blah blah
Notice that in this case the error monitor has spotted a problem with qmail's logging setup and
it's telling you. Imagine that.

E-Mail Message Not Delivered To Local or Remote Computer

When qmail does not deliver an e-mail message to the local or remote computer, qmail is either not running, or running but not delivering the e-mail messages to the local or remote computers. You need to verify whether or not the qmail daemons are running and also check the qmail-send logs for error messages. To verify the running of qmail daemons, you need to check the running status of all the processes of qmail. These qmail processes are:

qmail-send: The qmail command prompt displays the process name as user qmails.

qmail-clean: The qmail command prompt displays the process name as user qmailq.

qmail-rspawn: The qmail command prompt displays the process name as user qmailr.

qmail-lspawn: The qmail command prompt displays the process name as user root.

Note 

qmail daemons are small programs in UNIX that run when a process executes in UNIX.

The ps 'ef | grep qmail command lists the executing processes of qmail at the command line. The list of executing processes displays all the processes that are running. As a result, from this list of executing processes, you can check if the qmails, qmailq, qmailr, and root processes are running. You can check, which process is in the running state, through the list of qmail process. You need to configure qmail for that process to start running. If all the qmail processes are running, you need to verify the qmail-send log to identify the error in sending an e-mail message.

The log sequence of messages that are successfully sent to a remote computer from a local computer is:

new msg 9381
info msg 9381: bytes 300 from xy@abc.com qp 1234 uid 500
starting delivery 3975: msg 9381 to remote john@qmail.solutions.com
# The number of pending deliveries / total number of deliveries of e-mail messages.
status: local 0/10 remote 1/20
delivery 3975: success:
192.18.0.128_accepted_message./Remote_host_said:_250_ok_989756845_qp_15460/
status: local 0/10 remote 0/20
end msg 9381

In the above sequence of the messages:

new msg: Indicates that the qmail-send module has received a new e-mail message with queue ID 9381.

info msg: Indicates that john@qmail.solutions.com receives the e-mail message from xy@abc.com and is 300 bytes long.

starting delivery: Represents the starting of process to deliver the e-mail message to john@qmail.solutions.com. This message also assigns the ID, 3975, to the e-mail message.

status: Indicates that there is no local and only one remote delivery of e-mail message, which is pending.

delivery: Indicates that the delivery number, 3975, is complete and returns a confirmation message of the delivery of e-mail message from the server.

status message displayed after the e-mail message is delivered: Indicates that no local or remote deliveries are pending.

end msg: Indicates that the e-mail message has been delivered and removed from the queue.

When qmail is not able to send a local delivery, a message stating the reason of failure is displayed in the qmail-send log file, as:

delivery 3975: failure: No_mail_box_found
bounce msg 500 qp 1234

When qmail is not able to send a remote delivery, a message stating the reason of failure is displayed in the qmail-send log file, as:

delivery 3975: failure: Could_not_find_hostname_abc.com
bounce msg 500 qp 1234

As a result, the message in the qmail-send log file helps identify and fix the error in sending an e-mail message.

E-Mail Message Not Accepted from Remote Hosts

You can check whether or not the e-mail messages sent from the remote hosts to the local address are accepted. The e-mail messages sent from remote host are not accepted at local address because of the following reasons:

The qmail-smtpd service is not running.

The qmail-smtpd service is not accessible by remote hosts.

qmail is not configured.

The Domain Name Service (DNS) is not configured.

Note 

The qmail-smtpd service accepts or rejects e-mail messages through Simple Mail Transfer Protocol (SMTP).

To identify the reasons for the failure of the e-mail message being accepted at local address:

Verify if the qmail-smtpd service is active on the computer. To check for the active qmail-smtp service, you need to initiate a connection between a remote and a local computer using the telnet <port number> smtp command and break the connection without entering a command. The telnet <port number> smtp command searches for smtp at the port number specified with the telnet command. If the connection is established and a message is displayed, the qmail-smtp service is active.

Verify if the remote host can access the qmail-smtp service. Initiate the connection between the qmail-smtp service and a remote computer. If the connection fails, the qmail-smtp service may not be running on a computer.

Verify if qmail accepts e-mail messages from a domain. Send a message that a computer accepts or delivers using SMTP. If the remote computer rejects the message, check the /control/rcpthosts file. If the remote computer accepts the message and does not deliver the message to a remote computer, check the qmail-send logs for the error in delivering a message.

E-Mail Message Not Delivered To Local Address

qmail does not deliver an e-mail message to a local address when the end user does not exist or the name of an end user is not a valid user name. When qmail does not deliver an e-mail message to one or more local addresses, the Mail Transfer Agent (MTA) either rejects the e-mail message or stores the e-mail messages in a queue. To check for the error messages, if an e-mail message is not delivered to a local address:

Check the qmail-send logs for the error message, which displays the reason for failure. The error messages and the reason for failure are:

deliver 473: failure: Sorry,_no_mailbox_by_this_name/: Specifies that an end user with the specified user name does not exist.

delivery 130: deferral: /bin/sh:_qmail-procmail:_command_not_found: Specifies that an e-mail message is not delivered regardless of the valid e-mail address.

deferral: Uh-oh: home directory is writable or deferral: Uh-oh: .qmail file is writable: Specifies that the home directory permissions of an end user and the permissions of the .qmail file do not contain a permission, which is not specified in the conf-patrn configuration variable.

Verify that the e-mail message of an end user is not redirected to another end user by checking the content of the /var/qmail/assign file.

Verify that the value in the concurrencylocal control file is not set to 0.

E-Mail Message Not Delivered To Remote Address

qmail does not deliver the e-mail messages to a remote address when there is an error in the configuration of local qmail, configuration of remote qmail, or when the network is not accessible. The qmail-send logs display the error messages stating the following reasons for the failure in delivering an e-mail message to a remote address:

If the logs display a permanent error, either the remote address is invalid or the remote address is not accepting the e-mail message.

If the logs display a temporary error, either the connection between the local and the remote host is not established, or the remote host is connected to the local host but is temporarily unable to deliver the e-mail message.

If there is delay in receiving the error messages, a connection with the remote host is not established. Verify that the local host is connected to the network.

E-Mail Message Not Retrieved by End Users

When the end users are unable to retrieve a new e-mail message using the Post Office Protocol 3 (POP3) or Internet Message Access Protocol (IMAP) network mail protocols, the mailbox service is not installed, the mailbox service is not working, or Mail User Agent (MUA) is not configured. To check for the error in retrieving an e-mail message:

Check if the POP3 or IMAP service is installed.

Check the logs for the error messages.

Connect to the POP3 or IMAP service from a server to verify that the service is active.

Verify the end user authentication by logging on to the service with a user name and password.

Verify that the e-mail messages are delivered to the correct location.

Verify that MUA of an end user is configured with a server, protocol, authentication method, user name, and password.

E-Mail Messages Not Sent By The Local Users

When a local end user is unable to send an e-mail message, the SMTP service may not be working or MUA is not configured. To check for the error in sending an e-mail message:

Verify that SMTP is working.

Verify that the trusted hosts are granted relaying access. You need to add the Internet Protocol (IP) address of the trusted host in the /etc/tcp.smtp and /etc/tcp.smtp.cdb files.

Verify that MUA of an end user is configured with correct SMTP server.

Note 

Trusted hosts are the hosts that are authorized to access each other.

Appendix C: Troubleshooting Mailbox Conversion to qmail

You might encounter various problems while converting the mailboxes from the Exchange Server format, such as .pst, to a format supported by qmail, such as mbox. The problems can arise during the export of e-mail messages from Outlook, conversion of files from the Exchange Server format to the qmail format, or during the migration of calendaring services.

This appendix explains the various problems encountered during the conversion of mailboxes and describes how to troubleshoot these problems.

Problems Encountered while Exporting Outlook Files

The process of converting the mailboxes involves exporting of e-mail messages of Outlook to the .pst or .dbx format. If you are exporting the e-mail messages from Microsoft (MS) Outlook, the Import and Export wizard allows you to select the location where you want to store the exported files. Alternatively, if you are exporting the e-mail messages from Outlook Express, the Export option of Outlook Express does not provide the option to select the location where e-mail messages are exported. As a result, you need to first determine the location where Outlook Express stores the exported files, to convert these files to the formats supported by qmail.

You can determine the location where Outlook Express stores the exported files of a folder from the Properties dialog box of that folder. You can open the Properties dialog box of a folder by right-clicking the folder icon from the tree view of the Outlook Express main window and selecting Properties from the context menu.

Figure C-1 shows the Properties dialog box for the Outbox folder:

Click To expand: This figure shows the location of the Outbox folder where the e-mail messages of Outbox are stored.
Figure C-1: The Outbox Properties Dialog Box

Problems Encountered while Converting Outlook Files

You can convert a file from the .dbx to mbox format using the Dbxconv tool. These files generated by the Dbxconv tool have the mbx extension, and cannot be imported to Ximian Evolution. This problem can be solved by renaming the .mbx files to .mbox.

Problems Encountered while Converting Calendars

You can convert an Outlook calendar to the calendar of Ximian Evolution by using the Visual Basic (VB) macro, outlook2ical. You might not be able to run the macro even after successfully importing the macro into MS Outlook. This could be due to absence of references in the VB editor that are used to run the outlook2ical macro. The various references required to run the outlook2ical macro are:

Microsoft Forms 2.0 Object Library

Microsoft Office Runtime 1.0 Type Library

Microsoft Office 11.0 Object Library

Microsoft Outlook 11.0 Object Library

Microsoft Word 11.0 Object Library

OLE Automation

Visual Basic for Applications

You can verify whether the VB editor contains the required references by selecting Tools -> References from the main window of the VB editor. The References - Project 1 dialog box appears when you select Tools -> References, as shown in Figure C-2:

Figure C-2: The References - Project 1 Dialog Box

Note 

You can open the Visual Basic editor by selecting Tools -> Macros -> VB Editor from the Microsoft Outlook main window.

Appendix D: qmail End User License Agreement

A license for the software is written to consider the issues of copyright law and product liability law. There are two types of software licenses, proprietary software and free software. The proprietary software is not available free of cost and requires permissions for its use and modifications. The free software is available free of cost and does not need permissions for its use and modifications.

This appendix states the license agreement of qmail.

License

The author Dan Bernstein has the copyright for qmail, which is free software and is not distributed with a statement of user rights. You can distribute the qmail source code and the patches of qmail. You can also redistribute the unmodified qmail source distribution. You cannot distribute the modified qmail source code.

You can modify the source code when you install qmail but you cannot distribute the modified source code of qmail.

You can refer to the following links to refer to the actual license for distribution of the qmail source code and binary source:

http://cr.yp.to/softwarelaw.html.

http://cr.yp.to/qmail/dist.html.

http://cr.yp.to/qmail/var-qmail.html.

Index

A-D

Active Directory, Chapter 2: Overview of Exchange Server

Active Directory Connector, Exchange Server and Active Directory

ADC, Exchange Server and Active Directory

Binary RPM, Installing qmail from Binary RPM

broadcast, Chapter 8: Migrating Calendar Services

BSD, Installing and Configuring the OpenLDAP Server

DACL, SMTP Virtual Server

DB transactional backend, Structure of the /etc/openldap/slapd.conf File

dbx, Problems Encountered while Converting Outlook Files

Directory service to metabase service, Transport Dependencies of SMTP

Discretionary Access Control List, SMTP Virtual Server

DNS, Introducing Directory Services, Building qmail, Structure of the /etc/openldap/slapd.conf File, Using SMTP Daemon to Filter Known Spammers, Questions, Answers, E-Mail Message Not Accepted from Remote Hosts

Domain Name System, Introducing Directory Services

drop-down, Calendaring in qmail

DS2MB, Transport Dependencies of SMTP

DUL, Using Third-Party Filtering Tools

Index

E-G

ESMTP, Chapter 7: Setting up Authentication and Authorization

Exchange Server, Chapter 2: Overview of Exchange Server, Chapter 5: Migrating Existing Mails From Exchange Server, Appendix C: Troubleshooting Mailbox Conversion to qmail

EXE, Using SMTP Daemon to Filter Known Spammers

exim, Chapter 3: Overview of qmail

Extended Simple Mail Transfer Protocol, Chapter 7: Setting up Authentication and Authorization

EZMLM, Creating and Managing Mailing Lists

GNU, Answers

GnuPGP, Configuring KMail

GUI, Using qmailadmin Tool to Manage qmail

Index

H-I

HTML, The MIME Protocol, Installing qmailadmin

HTTP, Answers

HUP, Allowing Selective Relaying

Hyper Text Markup Language, The MIME Protocol

ics, Tools to Convert Calendars

IMAP, Describing the Role of MTAs and MUAs, Using the SMTP, Using Ximian Evolution, E-Mail Message Not Retrieved by End Users

Internet Information Server, ESMTP Authentication

Internet Message Access Protocol, Describing the Role of MTAs and MUAs, Using the SMTP

Internet Protocol, Introducing Directory Services

Interpersonal Message, Message Transfer Agent

IP, Introducing Directory Services, Modifying Configuration Files

IPM, Message Transfer Agent

Index

K-L

K Desktop Environment, Introducing KMail

KDC, Kerberos Modules

KDE, Introducing KMail

Kerberos, Chapter 7: Setting up Authentication and Authorization

Kerberos Key Distribution Center, Kerberos Modules

KMail, Chapter 5: Migrating Existing Mails From Exchange Server

LDAP, Overview of Exchange Server and qmail MTA, Transport Components, Chapter 6: Setting up Directory Services, Structure of the /etc/openldap/slapd.conf File, Chapter 7: Setting up Authentication and Authorization, Questions

LDIF, Using LDIF Files

Lightweight Directory Access Protocol, Overview of Exchange Server and qmail MTA, Transport Components

Lightweight Directory Application Protocol, Chapter 7: Setting up Authentication and Authorization

Linux, Chapter 3: Overview of qmail, Chapter 4: Installing and Running qmail, Chapter 5: Migrating Existing Mails From Exchange Server

local or remote computers, E-Mail Message Not Delivered To Local or Remote Computer

Index

M

macros, Tools to Convert Calendars

Mail Delivery Agent, Chapter 1: Introducing the Architecture of Messaging Systems, Chapter 3: Overview of qmail

Mail Transfer Agent, Chapter 1: Introducing the Architecture of Messaging Systems, Chapter 3: Overview of qmail

Mail User Agent, Chapter 1: Introducing the Architecture of Messaging Systems, Chapter 3: Overview of qmail

Mail User Agents, Chapter 5: Migrating Existing Mails From Exchange Server

MAPI, Storage Architecture of the Exchange Server

MAPS, Using Third-Party Filtering Tools

MDA, Chapter 1: Introducing the Architecture of Messaging Systems, Chapter 3: Overview of qmail, Advanced Configuration

MDBEF, Message Transfer Agent

Message Transfer Agent, Architecture of Exchange Server

Messaging Application Programming Interface, Storage Architecture of the Exchange Server

Microsoft Database Exchange Format, Message Transfer Agent

Microsoft Exchange Server, Chapter 7: Setting up Authentication and Authorization

Microsoft Office Outlook, Information Store

Microsoft Outlook, Exporting Files Locally

MLM, Creating and Managing Mailing Lists

MS Outlook, Problems Encountered while Converting Calendars

MTA, Chapter 1: Introducing the Architecture of Messaging Systems, Architecture of Exchange Server, Chapter 3: Overview of qmail, Installing qmail from Binary RPM, Chapter 9: Configuring qmail, E-Mail Message Not Delivered To Local Address

MUA, Chapter 1: Introducing the Architecture of Messaging Systems, Chapter 3: Overview of qmail, Tools to Convert Calendars, Using Mail User Agent (MUA) Junkmail Filtering, Answers, E-Mail Message Not Retrieved by End Users

MUAs, Chapter 5: Migrating Existing Mails From Exchange Server, Integrating Directory Services with qmail

multilog command, The qmail Services

MySQL, Licensing and Purchasing qmail

Index

N-O

Network News Transfer Protocol, Transport Dependencies of SMTP

New Technology Local Area Network, Chapter 7: Setting up Authentication and Authorization

NNTP, Transport Dependencies of SMTP

NT LAN, Chapter 7: Setting up Authentication and Authorization

OLE, Problems Encountered while Converting Calendars

Open Systems Interconnection, X.400 Connectors

ORDB, Using Third-Party Filtering Tools

OSI, X.400 Connectors

Outlook Express, Exporting Files Locally

Index

P

PAM, Using qmail Modules, Chapter 7: Setting up Authentication and Authorization

PFCA, Exchange Server and Active Directory

PGP, Configuring KMail

PIM, Working with the Calendaring System in Exchange Server and qmail

Pluggable Authentication Module, Chapter 7: Setting up Authentication and Authorization

POP, Mail Delivery and Protocols, Chapter 9: Configuring qmail, Installing and Configuring SpamAssassin

POP3, Describing the Role of MTAs and MUAs, Questions, E-Mail Message Not Retrieved by End Users

POSIX, Installing and Configuring the OpenLDAP Server

Post Office Protocol, Mail Delivery and Protocols

Post Office Protocol 3, Describing the Role of MTAs and MUAs

postfix, Chapter 3: Overview of qmail

Public Folder Connection Agreement, Exchange Server and Active Directory

Index

Q-R

qmail, Chapter 3: Overview of qmail, Chapter 4: Installing and Running qmail, Chapter 5: Migrating Existing Mails From Exchange Server, Converting Files from Microsoft Formats, Chapter 7: Setting up Authentication and Authorization, Calendaring in qmail, Chapter 9: Configuring qmail, Appendix B: Troubleshooting qmail, Appendix D: qmail End User License Agreement

QMQP, Using qmail Modules, Modifying Configuration Files

RAS, X.400 Connectors

RBL, Using Third-Party Filtering Tools

RCA, Exchange Server and Active Directory

Recipient Connection Agreement, Exchange Server and Active Directory

Remote Access Services, X.400 Connectors

Remote Procedure Call, Message Routing Within the Same Routing Group

RPC, Message Routing Within the Same Routing Group

RPMs, Chapter 4: Installing and Running qmail

RSS, Using Third-Party Filtering Tools

RSVP, Calendaring in qmail

Index

S

SBL, Using Third-Party Filtering Tools

Secure Socket Layer, Using Ximian Evolution, Using PAM for Security

sendmail, Chapter 3: Overview of qmail

Simple Mail Transfer Protocol, Describing the Role of MTAs and MUAs, Transport Components, Architecture of qmail

SMTP, Describing the Role of MTAs and MUAs, Transport Components, Architecture of qmail, Installing qmail from Binary RPM, Using Ximian Evolution, Using qmail Modules, Chapter 9: Configuring qmail, Chapter 10: Spam Filtering with qmail, Questions, E-Mail Message Not Accepted from Remote Hosts

SMTP protocol, Message Transfer Agent

Solaris, Chapter 3: Overview of qmail

SpamAssassin, Licensing and Purchasing qmail

SQL Server, Licensing and Purchasing qmail

SSL, Using Ximian Evolution, Using PAM for Security, Answers

Index

T-V

TCP, The POP3 Protocol, Using the POP, Rejecting SMTP Connections at Network Level, Questions

Transmission Control Protocol, The POP3 Protocol, Using the POP

UID, Answers

Unix, Chapter 3: Overview of qmail, Installation Prerequisites, Chapter 9: Configuring qmail, Answers

URL, Using LDIF Files, Configuring POP

Variable Envelope Return Path, Mail Delivery and Protocols

VB, Problems Encountered while Converting Calendars

vcs, Tools to Convert Calendars

VERP, Mail Delivery and Protocols

Visual Basic, Problems Encountered while Converting Calendars

Index

W-X

Windows 2000, X.400 Connectors

Ximian, Chapter 5: Migrating Existing Mails From Exchange Server

Ximian Evolution, Problems Encountered while Converting Outlook Files

Ximian Evolution tool, Tools to Convert Calendars

List of Figures

Chapter 1: Introducing the Architecture of Messaging Systems

Figure 1-1: Parts of the E-mail System

Chapter 2: Overview of Exchange Server

Figure 2-1: The First Properties Dialog Box for Routing Group Connector

Figure 2-2: The First Properties Dialog Box

Figure 2-3: The TCP Properties Dialog Box

Figure 2-4: The First TCP Connector Properties Dialog Box

Figure 2-5: The General Tab of the Default SMTP Virtual Server Properties Dialog Box

Figure 2-6: The Access Tab of the Default SMTP Virtual Server Properties Dialog Box

Figure 2-7: The Messages Tab of the Default SMTP Virtual Server Properties Dialog Box

Figure 2-8: The Delivery Tab of the Default SMTP Virtual Server Properties Dialog Box

Figure 2-9: Inbound Message Flow

Figure 2-10: Outbound Message Flow

Figure 2-11: Message Routing on the Same Server

Figure 2-12: Message Routing in the Same Routing Group

Figure 2-13: Message Routing to a Different Routing Group

Figure 2-14: Message Routing to an External Organization Server

Chapter 3: Overview of qmail

Figure 3-1: Interconnection of qmail Modules

Figure 3-2: Working of qmail

Chapter 4: Installing and Running qmail

Figure 4-1: The Output of the ./collate.sh Command

Figure 4-2: The Output of the make setup check Command

Figure 4-3: The Output of the ./config-fast qmail.solutions.com Command

Figure 4-4: The Output of the patch and make setup check Commands

Figure 4-5: The Output of the ./package/install Command

Figure 4-6: The Output of the qmailctl stat Command

Figure 4-7: Output of the sh inst_check Command

Figure 4-8: Output of the configure Command

Figure 4-9: Output of the make Command

Figure 4-10: Output of the make install Command

Figure 4-11: Running the qmailadmin Tool

Figure 4-12: Login Screen of the qmailadmin Tool

Figure 4-13: The main menu Screen

Figure 4-14: The Email Accounts Screen

Figure 4-15: The Forward Screen of the Qmailadmin Tool

Figure 4-16: Adding the Forward Account

Figure 4-17: The Add Mail Robot Screen of the qmailadmin Tool

Figure 4-18: The Mail Robots Screen

Figure 4-19: The Add Mailing List Screen

Figure 4-20: The Mailing Lists Screen

Figure 4-21: The Add Subscriber to Mailing List Screen

Figure 4-22: The List Subscriber Screen

Chapter 5: Migrating Existing Mails From Exchange Server

Figure 5-1: The Import and Export Wizard Screen

Figure 5-2: The Export to a File Screen

Figure 5-3: The Export Personal Folders Screen

Figure 5-4: Specifying the Location of the Exported Files

Figure 5-5: The Export Messages Dialog Box

Figure 5-6: Output of the dbxconv Command

Figure 5-7: Output of the tar Command

Figure 5-8: Output of the make Command

Figure 5-9: Conversion of backup.pst to the mbox Format

Figure 5-10: Output of the gunzip Command

Figure 5-11: Conversion from mbox to maildir

Figure 5-12: The Ximian Evolution Main Window

Figure 5-13: The Identity Page of the Evolution Setup Assistant Wizard

Figure 5-14: The Receiving Mail Page of the Evolution Setup Assistant Wizard

Figure 5-15: IMAP Server Configuration Settings

Figure 5-16: Configuring Options for Checking New E-mail Messages

Figure 5-17: The Sending Mail Page

Figure 5-18: The Account Management Page

Figure 5-19: The Timezone Page

Figure 5-20: The Mail Accounts Page

Figure 5-21: The Folder Settings Page

Figure 5-22: The Mail Preferences Page

Figure 5-23: The Compose Preferences Page

Figure 5-24: The Signatures Screen

Figure 5-25: The Edit signature Windows

Figure 5-26: The Spell Checking Screen

Figure 5-27: The Calendar and Tasks Page

Figure 5-28: The Directory Servers Page

Figure 5-29: The Server Information Screen

Figure 5-30: The Connecting to Server Page

Figure 5-31: The Searching the Directory Page

Figure 5-32: The Display Name Page

Figure 5-33: Displaying the Newly Added LDAP Server

Figure 5-34: The Font Preferences Page

Figure 5-35: The Summary Preferences Page

Figure 5-36: The Compose a Message Window

Figure 5-37: The Importer Type Screen of the Evolution Import Assistant Wizard

Figure 5-38: The Select a File Screen

Figure 5-39: The Select folder Dialog Box

Figure 5-40: The Authorization Dialog Dialog Box

Figure 5-41: The KMail Main Window

Figure 5-42: Reading E-mail Messages

Figure 5-43: The Composer Window

Figure 5-44: The Attach File Dialog Box

Figure 5-45: The kmail Dialog Box

Figure 5-46: The KMail & KAddressBook Import Filters Dialog Box

Chapter 6: Setting up Directory Services

Figure 6-1: The Address Book Window

Figure 6-2: The Directory Server Properties Dialog Box

Figure 6-3: The Address Book Window with E-mail Addresses

Figure 6-4: The New Card for the User, John, Dialog Box

Figure 6-5: The Advanced Address Book Search Window

Figure 6-6: Displaying the Search Results

Figure 6-7: The Microsoft Outlook Windows

Figure 6-8: The Internet Accounts Dialog Box

Figure 6-9: The Internet Directory Server Name Screen

Figure 6-10: The Check E-mail Addresses Screen

Figure 6-11: The LDAP Server Account Added in the List of Mail Accounts

Figure 6-12: The Advanced Tab of the linuxser1.smartdevelopers.com Properties Dialog Box

Chapter 8: Migrating Calendar Services

Figure 8-1: The Calendar Page

Figure 8-2: The Meeting-Appointment Window

Figure 8-3: The Appointment Recurrence Window

Figure 8-4: The Meeting-Appointment Window for Setting Reminders

Figure 8-5: The Reminder Sound Dialog Box

Figure 8-6: The Plan a Meeting Dialog Box

Figure 8-7: The Select Attendees and Resources Dialog Box

Figure 8-8: Selecting the Time for Meeting

Figure 8-9: The Meeting Window

Figure 8-10: The Event Window

Figure 8-11: The Appointment Recurrence Dialog Box

Figure 8-12: Displaying the Annual Event on the Calendar Page

Figure 8-13: The Calendar Page in Ximian Evolution

Figure 8-14: The Appointment Window

Figure 8-15: The Appointments Added on The Calendar Page

Figure 8-16: The Reminder Page

Figure 8-17: The Meeting Page

Figure 8-18: The Meeting Properties of Joe Smith

Figure 8-19: The Task Window

Figure 8-20: The Summary Window

Figure 8-21: The Security Dialog Box

Figure 8-22: The Macros Dialog Box

Figure 8-23: The Save iCal Step 1/3 Screen

Figure 8-24: The Save iCal Step 2/3 Screen

Figure 8-25: The Save iCal Step 1/3 Screen for Specifying Location

Figure 8-26: The Select a Continue List screen.

Figure 8-27: The Select a Folder Dialog Box

Chapter 9: Configuring qmail

Figure 9-1: Information About the inetd Process

Figure 9-2: Initialization of tcp Server

Figure 9-3: Initialization of Selective Relaying

Figure 9-4: Output of the qmailctl reload Command

Figure 9-5: The E Z Mailing List Manager Screen

Figure 9-6: The Create a New List Screen

Figure 9-7: The Subscribers to testing Screen

Figure 9-8: The Edit the List Configuration Screen

Figure 9-9: The Confirm deletion of testing Screen

Figure 9-10: Output of the make Command

Figure 9-11: Output of the make setup check Command

Chapter 10: Spam Filtering with qmail

Figure 10-1: Applying The QMAILQUEUE Patch

Appendix A: Frequently Asked Questions

Figure A-1: The Output of the qmailctl help Command

Figure A-2: The Meeting - Appointment Window

Appendix C: Troubleshooting Mailbox Conversion to qmail

Figure C-1: The Outbox Properties Dialog Box

Figure C-2: The References - Project 1 Dialog Box

List of Tables

Chapter 1: Introducing the Architecture of Messaging Systems

Table 1-1: Comparing qmail with Other MTAs

Chapter 3: Overview of qmail

Table 3-1: qmail-queue Return Codes

Chapter 4: Installing and Running qmail

Table 4-1: Different Directories for Binary RPMs and Tar Files

Table 4-2: Various Mailbox Types

Chapter 9: Configuring qmail

Table 9-1: Configuration Files that use the qmail-send Module

Table 9-2: Configuration Files that use the qmail-smtpd Module

Table 9-3: Configuration Files that Use the qmail-inject Module

Table 9-4: Configuration Files that Use the qmail-remote Module

Table 9-5: Configuration Files in Other Modules

List of Listings

Chapter 4: Installing and Running qmail

Listing 4-1: Adding User Entries in the /etc/passwd File

Listing 4-2: The rc Script File

Listing 4-3: Displaying the Contents of the qmailctl Script File

Listing 4-4: Displaying the Contents of the run Script File

Chapter 6: Setting up Directory Services

Listing 6-1: Sample /etc/openldap/slapd.conf File

Listing 6-2: Format of the /etc/openldap/slapd.conf File

Listing 6-3: Specifying the Access Control

Listing 6-4: Modifying the /etc/openldap/slapd.conf File

Listing 6-5: The smartdevelopers.com.ldif File

Listing 6-6: Adding Groups

Chapter 7: Setting up Authentication and Authorization

Listing 7-1: Parameters of the Login Configuration File

Listing 7-2: Configuring the Login Service in the pam.conf File

Listing 7-3: Configuring the LDAP Account Management Module

Listing 7-4: Configuring the LDAP Password Management Module

Listing 7-5: Configuring the LDAP Password Management Module for Remote Accounts

Chapter 10: Spam Filtering with qmail

Listing 10-1: The run File Script

Listing 10-2: Script of the smtprules.cdb File

Listing 10-3: Script of the CHECKATTACH Patch

Listing 10-4: Script of the CHECKSUBJ Patch

Listing 10-5: Script of the CHECKFILE Patch

Listing 10-6: The Default local.cf File