Before you can start sending your automated e-mail messages off to the universe, you’ll need to ensure that your Linux system has an MTA package running and that it’s configured correctly. This is no small task in itself, but fortunately, some Linux distributions provide some basic tools to help you out.This section walks you through the basics of the two most popular e-mail MTA programs used in Linux: sendmail and Postfix. While there have been complete books written on properly configuring each of these packages, we’ll just look at the basics to see how to get e-mails off the Linux system and into your inbox.
The sendmail MTA package is one of the most popular open source MTA packages used by Internet mail servers. In the past it had been plagued with stories about backdoors and security flaws; however, it has been rewritten not only to remove the security flaws but also to incorporate many newer MTA features such as spam control. The newer versions of the sendmail program have proven to be secure as well as versatile.
Parts of the sendmail program
The main executable program is called sendmail. It normally runs in background mode, listening for SMTP connections from remote mail servers, and forwarding outbound messages from local users.Besides the main sendmail program, there’s a configuration file and several tables that it uses tocontain information used while processing incoming and outgoing mail messages. Table below lists all the parts used in a normal sendmail installation.
Unless you’re running the main mail server for a corporation or Internet service provider, all you’ll need to worry about is the sendmail.cf configuration file. In fact, many Linux distributions that use sendmail create and configure a core sendmail.cf configuration file for you automatically that should work just fine in most simple applications.
The sendmail.cf file
The sendmail program needs to be told how to handle messages as the server receives them. As an MTA, sendmail processes incoming mail and redirects it to another mail package, either on a remote system or on the local system. The configuration file is used to direct sendmail how to manipulate the destination mail addresses to determine where and how to forward the messages.The default location for the configuration file is /etc/mail/sendmail.cf.
The sendmail.cf file consists of rule sets that parse the incoming mail message and determine what actions to take. Each rule set is used to identify certain mail formats and instruct sendmail how to handle that message.As the sendmail program receives a message, it parses the message header and passes the message through the various rule sets to determine an action to take on the message. The sendmail configuration file includes rules that allow sendmail to handle mail in many different formats. Mail received from an SMTP host has different header fields than mail received from a local user. The sendmail program must know how to handle any mail situation.
Rules also have helper functions defined in the configuration file. There are three different types of helper functions that you can define:
The configuration file is made up of a series of classes, macros, options, and rule sets. Each function is defined as a single text line in the configuration file.Each line in the configuration file begins with a single character that defines the action for that line. Lines that begin with a space or a tab are continuation lines from a previous action line.
Lines that begin with a pound sign (#) indicate comments and are not processed by sendmail.
The action at the beginning of the text line defines what the line is used for. Table below shows the standard sendmail actions and what they represent.
As I mentioned, most likely you won’t have to start from scratch with your sendmail.cf configuration file, the Linux distribution should create a standard template file for you. Figure below shows part of the sendmail.cf configuration file from a Debian-based Linux system.
Most likely, the only piece you’ll have to worry about is if you must use a smart host to forward mail for you. The DS configuration line controls this feature:
Just add the hostname of the smart host immediately after the DS tag.
The Postfix software package is quickly becoming one of the more popular e-mail packages available for Unix and Linux systems. Postfix was developed by Wietse Venema to provide an alternative MTA for standard Unix-type servers. The Postfix software is capable of turning any Unix or Linux system into a fully functional e-mail server.
It is the responsibility of the MTA package to manage messages that come into or leave the mail server. Postfix accomplishes this message tracking by using several different modular programs, and a system of mail queue directories. Each program processes messages through the various message queues until they are delivered to their final destinations. If at any time the mail server crashes during a message transfer, Postfix can determine what queue the message was last successfully placed in and attempt to continue the message processing.
Parts of the Postfix system
The Postfix system consists of several mail queue directories and executable programs, all interacting with each other to provide mail service. Figure 26-6 shows a block diagram of the core Postfix parts.
Each piece of the Postfix block diagram provides a different function for the whole e-mail process. The following sections describe the different pieces of the Postfix block diagram in more detail.
The Postfix package utilizes a master program that runs as a background process at all times. The master program allows Postfix to spawn programs that scan the mail queues for new messages and send them to the proper destinations. The core programs can be configured to remain running for set times after they are utilized. This allows the master program to reutilize a running helper program if necessary, saving processing time. After a set time limit, the helper program quietly stops itself.
The master program is used to control the overall operation of Postfix. It is responsible for starting other Postfix processes as needed. The qmgr and pickup programs are configured to remain as background processes longer than other core programs. The pickup program determines when messages are available to be routed by the Postfix system. The qmgr program is responsible for the central message routing system for Postfix.
Table below shows other core programs that Postfix uses to transfer mail messages.
Table: The Postfix Core Programs
Unlike some other MTA packages, Postfix uses several different message queues for managing e-mail messages as they are processed. Each message queue contains messages in a different message state in the Postfix system. Table below lists the message queues that are used by Postfix.
If the Postfix system should be shut down at any time, messages remain in the last queue in which they were placed. When Postfix is restarted, it will automatically begin processing messages from the queues.
Postfix configuration files
The next block in the diagram is the Postfix configuration files. The configuration files contain information that the Postfix programs use when processing messages. Unlike some other MTA programs, it’s possible to change configuration information while the Postfix server is running and issue a command to have Postfix load the new information without completely downing the mail server.
There are three Postfix configuration files, which are located in a common Postfix directory. Often the default location for this directory is /etc/postfix. Usually, all users have access to view the configuration files, whereas only the root user has the ability to change values within the files. Of course, this can be modified for your own security situation. Table below lists the Postfix configuration files.
Table: Postfix Configuration Files
The install.cf configuration file allows you to retrieve installation parameters that were used when the Postfix software was first installed on the system. This provides an easy way to determine which features are or aren’t available in the software setup.The master.cf configuration file controls the behavior of the core Postfix programs. Each program is listed in a separate line along with the parameters to control its operation. Here’s a sample master.cf file with default settings.# ===================================================================
The master.cf configuration file also includes lines for directing Postfix on how to interface with external MDA software, such as Procmail.
The Postfix operational parameters are set in the main.cf configuration file. All of the Postfix operational parameters have default values that are implied within the Postfix system. If a parameter value is not present in the main.cf file, its value is preset by Postfix. If a parameter value is present in the main.cf file, its contents override the default value.
Each Postfix parameter is listed on a separate line in the configuration file along with its value, in the form:
parameter = value
Both parameter and value are plain text strings that can be easily read and changed if necessary. The Postfix master program reads the parameter values in the main.cf file when Postfix is first started, and again whenever a postfix reload command is issued.
Two examples of Postfix parameters are the myhostname and mydomain parameters. If they are not specified in the main.cf configuration file, the myhostname parameter assumes the results of a gethostname() command on the Linux system, whereas mydomain assumes the domain part of the default myhostname parameter. Often a single mail server will handle mail for an entire domain. This is an easy setting in the Postfix configuration file:myhostname = mailserver.smallorg.org
When Postfix starts, it will recognize the local mail server as mailserver.smallorg.org and the local domain as smallorg.org and will ignore any system set values.
If you need to specify a smart host, do that with the relayhost parameter:
relayhost = myisp.com
You can also specify an IP address here, but it must be enclosed in square brackets.
Shell Scripting Related Interview Questions
|Perl Scripting Interview Questions||Python Interview Questions|
|Linux Interview Questions||Linux Embedded systems Interview Questions|
|AWK Interview Questions||BioPerl Interview Questions|
|Sed (Stream Editor) Interview Questions||Advanced Linux Interview Questions|
|Unix/Linux Interview Questions||Unix Shell Scripting Interview Questions|
Shell Scripting Tutorial
Starting With Linux Shells
Getting To The Shell
Basic Bash Shell Commands
More Bash Shell Commands
Using Linux Environment Variables
Basic Script Building
Understanding Linux File Permissions
Working With Editors
Using Structured Commands
More Structured Commands
Handling User Input
Adding Color To Scripts
Introducing Sed And Gawk
The Ash Shell
The Tcsh Shell
The Korn Shell
The Zsh Shell
Using The Web
Using A Database
Shell Script For Administrators
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.