Pages

Wednesday 22 June 2011

Sendmail Configuration in AIX


The information on this document describes how to configure sendmail as a basic mail server,
and applies to AIX Versions 5.3TL6, 6.1.

Configure the file /etc/mail/sendmail.cf
--------------------------------------------------------
# vi /etc/mail/sendmail.cf

Uncomment the entry for local-host-names, it defines which domains the mail server will be responsible for.
# Fw/etc/mail/local-host-names

Uncomment the entry for relay-domains, it will be used to defined which hosts are allowed to use this server as a mail relay.
# FR-o /etc/mail/relay-domains

If the mail server is behind a firewall, you will need port 25 open. Typically a mail server has direct access through the firewall. But if the mail server does not have direct access through the firewall, then it will need to point to another mail server that can. In this case the admin can append the hostname of the mail server after the "DS".

# "Smart" relay host (may be null)
DSmailserver.domain.com

The parameters mentioned above are the most common ones. There are many other features that can be setup for a mail server, such as Mailertable, Genericstable, Virtusertable, etc. All these features are well documented in the following website.

http://www.sendmail.org/m4/features.html

Creating database file and starting sendmail
-----------------------------------------------------------------

Create the /etc/mail/local-host-names database file. It will contain all the domains that this mail server will be accepting mail for.

# vi /etc/mail/local-host-names
examples:
testdomain.com
somedomain.com

Create the /etc/mail/relay-domains database file. It should contain all the hostnames, subnets or domains that will be allowed to use this server as a mail relay.

#vi /etc/mail/relay-domains
examples:
testsystem
testdomain.com
10.1.1.1
192.168

Restart sendmail daemon with the new configuration
-----------------------------------------------------------------------------------

To stop sendmail run the following command.
# stopsrc -s sendmail

To start sendmail run the following command.
# startsrc -s sendmail -a "-bd -q30m"

To check if sendmail daemon is active run the following command.
# lssrc -s sendmail
Subsystem Group PID Status
sendmail mail 10352 active

Autostart of the sendmail daemon (/etc/rc.tcpip)

The sendmail daemon is started from the /etc/rc.tcpip file. To configure this file so that the sendmail daemon will be started at system boot time:

1. Edit the /etc/rc.tcpip file.
2. Find the line that begins with start /usr/lib/sendmail. By default, this line should be uncommented; that is, there is no # (pound sign) at the beginning of the line. However, if it is commented, delete the pound sign.

Specifying time values in sendmail (in rc.tcpip)

The interval at which the sendmail daemon processes the mail queue is determined by the value of the -q flag when the daemon starts.
The /etc/rc.tcpip file contains a variable called the queue processing interval (QPI), which it uses to specify the value of the -q flag when it starts the sendmail daemon. By default, the value of QPI is 30 minutes. To specify a different queue processing interval:

1. Edit the /etc/rc.tcpip file.
2. Find the line that assigns a value to the qpi variable, such as qpi=30m.
3. Change the value assigned to the qpi variable to the time value you prefer using the values shown in the next section.

Specifying time values in sendmail (not in rc.tcpip)

To set the message time-out and queue processing interval, you must use a specific format for the time value. The format of a time value is -qNumberUnit, where Number is an integer value and Unit is the unit letter. Unit may have one of the following values:

s Seconds
m Minutes
h Hours
d Days
w Weeks

To process the queue every 15 days, issue the command:
#sendmail -q15d

To process the queue every 15 hours, issue the command:
#sendmail -q15h

To process the queue every 15 minutes, issue the command:
#sendmail -q15
#sendmail -q15m
The mail queue is a directory that stores data and control files for mail messages that the sendmail command delivers. By default, the mail queue is /var/spool/mqueue.

The contents of the queue can be printed using the mailq command (or by specifying the -bp flag with the sendmail command).

The mail queue directory /var/spool/mqueue contains four types of mail queue files:
1) Data file
2) Control file
3) Temporary file
4) Transcript file

Each message in the queue has four files associated with it. For example, if a message has a queue ID of AA00269, the following files are created and deleted in the mail queue directory while the sendmail command tries to deliver the message:

dfAA00269Data file
qfAA00269Control file
tfAA00269Temporary file
xfAA00269Transcript file

Forcing the mail queue to run

In some cases, the mail queue becomes unresponsive. To force a queue to run,
#sendmail -q –v

Moving the mail queue

When a host goes down for an extended period, many messages routed to (or through) that host may be stored in your mail queue. As a result, the sendmail command spends a long time sorting the queue, severely degrading your system's performance. If you move the queue to a temporary place and create a
new queue, the old queue can be run later when the host returns to service. To move the queue to a temporary place and create a new queue:

1. Stop the sendmail daemon.
2. Move the entire queue directory by entering:
#cd /var/spool
#mv mqueue omqueue
3. Restart the sendmail daemon.
4. Process the old mail queue by entering:
#sendmail -oQ/var/spool/omqueue -q
The -oQ flag specifies an alternate queue directory. The -q flag specifies to run every job in the queue. To get a report about the progress of the operation, use the -v flag. This operation can take a long time.
5. Remove the log files and the temporary directory when the queue is empty by entering:
#rm /var/spool/omqueue/*
#rmdir /var/spool/omqueue


Mail logs

The sendmail command logs mail system activity through the syslogd daemon. The syslogd daemon must be configured and running for logging to occur. Specifically, the /etc/syslog.conf file may contain the uncommented line:

mail.debug /var/spool/mqueue/log

and than

#refresh -s syslogd

If the /var/spool/mqueue/log file does not exist, you must create it by entering the command:

#touch /var/spool/mqueue/log

Displaying mailer information

The statistics kept in the /var/tmp/sendmail.st file are in a database format that cannot be read as a text file. To display the mailer statistics, enter the command:

#mailstats


Mail addressing

Mail is sent to a user’s address. How you address mail to another user depends upon the user’s location with respect to your system. The address would depend on whether you are sending the mail:

·         To users on your local system.
·         To users on your network.
·         To users on a different network.
·         Over a BNU or UUCP link.


To address mail to users on your local system

To send a message to a user on your local system (to someone whose login name is listed in your /etc/passwd file), use the login name for the address. At your system command line prompt, you can use the mail command in the way shown in the following example:

# mail LoginName

If neo is on your system and has the login name smith, use the command:
# mail neo

To address mail to users on your network

To send a message through a local network to a user on another system, at the command line, enter:

# mail LoginName@SystemName

For example, if neo is on system test, use the following command to create and send a message to him:

# mail neo@test

To address mail to users on a different network

If your network is connected to other networks, you can send mail to users on the other networks. The address parameters differ depending on how your network and the other networks address each other and how they are connected.

Using a central database of names and addresses

Use the mail command in the way shown in the following example:
# mail LoginName@SystemName

Using domain name addressing

Use the mail command in the way shown in the following example:

For example, to send mail to a user john, who resides in a remote network with a domain name in.ibm.com, use the following command:

To address mail over a BNU or UUCP link

To send a message to a user on another system connected to your system by the Basic Networking Utilities (BNU) or another version of UNIX-to-UNIX Copy Program (UUCP), you must know the login name, the name of the other system, and the physical route to that other system. When your computer has a BNU or UUCP link, you can use the command as shown in the following:

# mail UUCPRoute!LoginName

When the BNU or UUCP link is on another computer, use the mail command, as shown below:

# mail @InternetSystem:UUCPSystem!username

List of mail commands

This list includes commands for using and managing the mail program.

mailq                                      Prints the contents of the mail queue.
mailstats                                 Displays statistics about mail traffic.
newaliases                             Builds a new copy of the alias database from the
/etc/aliases file.
sendmail                                Routes mail for local or network delivery.
smdemon.cleanu                 Cleans up the sendmail queue for periodic housekeeping

List of mail files and directories

This list of files and directories is arranged by function.

The mail program
The following is a list of files associated with the mail program. $HOME/.mailrc Enables the user to change the local system defaults for the mail program.

$HOME/mbox                       Stores processed mail for the individual user.
/usr/bin/Mail, /usr/bin/mail, and /usr/bin/mailx

Specifies three names linked to the same program. The mail program is one of the user interfaces to the mail system.
/var/spool/mail                    Specifies the default mail drop directory. By default, all mail is delivered to the /var/spool/mail/UserName file.
/var/spool/mqueue             Contains the log file and temporary files associated with the messages in the mail queue

The sendmail command

The following is a list of files associated with sendmail:

/usr/sbin/sendmail                              The sendmail command.
/usr/ucb/mailq                                     Links to the /usr/sbin/sendmail. Using mailq is equivalent to using the /usr/sbin/sendmail –bp command.
/usr/ucb/newaliases                           Links to the /usr/sbin/sendmail file. Using newaliases is equivalent to using the /usr/sbin/sendmail -bi command.
/usr/sbin/mailstats                               Formats and prints the sendmail statistics as found in the
                                                                /etc/sendmail.st file, if it exists. The
/etc/sendmail.st file is the default, but you can specify an alternative file.
/etc/aliases                                           Describes a text version of the aliases file for the sendmail command. You can edit this file to create, modify, or delete aliases for your system.
/etc/sendmail.cf                                   Contains the sendmail configuration information in text form. Edit the file to change this information.
/etc/sendmail.cfDB                              Contains the processed version of the /etc/sendmail.cf configuration file. This file is created from the /etc/sendmail.cf file when you run the
/usr/sbin/sendmail -bz command.
/etc/sendmail.nl                                   Contains the sendmail National Language Support (NLS) configuration information in text form. Edit the file to change this information.
/usr/lib/smdemon.cleanu                  Specifies a shell file that runs the mail queue and maintains the sendmail log files in the /var/spool/mqueue directory.
/var/tmp/sendmail.st                          Collects statistics about mail traffic. This file does not grow. Use the /usr/sbin/mailstats command to display the contents of this file.
/var/spool/mqueue                             Describes a directory containing the temporary files associated with each message in the queue. The directory can contain the log file.

No comments:

Post a Comment

Twitter Bird Gadget