• Aucun résultat trouvé

Current implementations of sendmail for Linux are available as a binary distribution. As mentioned previously, most distributions of Linux install sendmail during installation (if you selected the package for installation). Be sure to visit your distribution's Web site for a prebuilt package.

Otherwise, you can download the sendmail (source) package, unpack it, and execute the make linux

command at the command line.

As with anything else related to Linux (and UNIX), you want to get things configured with a minimum of effort and with some level of accuracy.

Obtaining sendmail

Most modern distributions of Linux include the sendmail package. Be sure to check your distribution media if sendmail is not installed. In a pinch, you can try the which command to see if the sendmail executable exists, as shown in the following dialog:

stimpy $ which sendmail /usr/sbin/sendmail stimpy $

The which command found the sendmail executable in the /usr/sbin directory. In contrast, the following dialog demonstrates the use of the which command to locate the sendmail executable. Since sendmail exists on this system, half the battle is getting the sendmail system up and running. Most of the work is in verifying the configuration files.

stimpy $ which sendmail

which: no sendmail in (/sbin:/usr/sbin:/usr/local/sbin//root/bin:/usr/local/bin:/usr/

bin:/usr/X11R6/bin:/bin:/usr/lib/java/bin:/var/lib/dosemu:/usr/games/bin:/usr/games:/

opt/gnome/bin:/opt/kde/bin:/usr/openwin/bin:/usr/lib/pgsql/bin:/opt/pilotsdk/bin) stimpy $

In this dialog, you can see that the which command could not find sendmail in the usual locations. This does not mean that sendmail does not exist on your system. You can perform an exhaustive search using the find command, as shown in the following dialog:

stimpy $ find / -name sendmail -print /etc/permissions.d/sendmail

/sbin/init.d/sendmail /usr/doc/packages/sendmail

/usr/doc/susehilf/raw_whatis/sendmail /usr/sbin/sendmail

/usr/lib/sendmail /usr/share/sendmail stimpy $

Checking the distributions of Linux on my system - Red Hat 6.1, SuSE 6.3, Slackware 7.0, and TurboLinux 6.0 - reveals the sendmail executable in the /usr/sbin directory. The one exception, Caldera 2.3, places the sendmail executable in the /usr/libexec/sendmail directory.

If you do not have sendmail installed, and the package is not available on your distribution media, you can download the sendmail package from the ftp://ftp.sendmail.org FTP site. You will find the sendmail package available as a compressed tar file (*.Z) and a gzipped tar file (*.gz). It is recommended that you download the gzipped package, because it is smaller in size, thereby making the download quicker.

Building the sendmail Package

First of all, you need to unpack the source distribution. This is easily achieved using the tar command, as shown in the following dialog:

stimpy $ tar -xzvf sendmail.x.x.x.tar.gz stimpy $

The x.x.x represents the version of sendmail you are using. The current version is 8.10.0, making the name of the file sendmail.8.10.0.tar.gz.

A number of directories are created, and all required files are extracted and placed in their appropriate directory. As with any other package to be built, you should first examine the README file(s). In a nutshell, the process is as follows:

1. Read any relevant README files. They will point you to other files that are important.

2. Create any necessary site configuration build files, as noted in devtools/Site/README.

3. Execute the Build script found in the ./sendmail directory.

4. Change to the cf/cf directory, and use the cp command to create a new *.mc file from the generic platform.mc file provided. Finally, execute Buildfilename.cf.

5. Copy filename.cf to the /etc/mail/sendmail.cf directory. Finally, install the sendmail

The following dialog demonstrates some of the initial operations required:

All of these commands place the Linux-specific site file in the expected directory. Next, we need to build the package, or sendmail executable. The following dialog demonstrates this:

stimpy $ pwd

/tmp/sendmail-8.10.0 stimpy $ ./Build Making all in:

/tmp/sendmail-8.10.0/libsmutil

Configuration: pfx=, os=Linux, rel=2.2.13, rbase=2, rroot=2.2, arch=i586, sfx=

Using M4=/usr/bin/m4

Creating ../obj.Linux.2.2.13.i586/libsmutil using ../devtools/OS/Linux ...

...

cc -o vacation -L../libsmdb -L../libsmutil vacation.o ...

groff -Tascii -man vacation.1 > vacation.0 || cp vacation.0.dist vacation.0 make[1]: Leaving directory `/tmp/sendmail-8.10.0/...

stimpy $

The script to execute is Build (shown in bold text), which is found in the base sendmail directory, shown as sendmail-8.10.0 in this example. Building the package is quite easy because most of the hard work is handled by the Build script file. The Build message output is quite extensive, much more than what is revealed in the preceding dialog. The complete build process should take no longer than a couple of minutes.

To confirm the successful build of the sendmail binary, you can execute sendmail as shown in the following dialog:

stimpy $ ./sendmail -d0.1 -bt < /dev/null Version 8.10.0

Compiled with: LOG MATCHGECOS MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETUNIX NEWDB QUEUE SCANF SMTP USERDB XDEBUG

/etc/mail/sendmail.cf: line 0: cannot open: No such file or directory stimpy $

The next step is to create the .cf file for the Linux platform. This process is detailed in the following section.

Building the .cf File

For construction of the .cf file, the Build script executes the m4 macro processor, which uses an .mc

file as input.

When the sendmail command first executes, it reads a configuration file named sendmail.cf, found in the /etc/mail directory. Proper configuration of this file can be an overwhelming task. Fortunately, there are tools that can make this task much easier. This section briefly discusses the creation of the

sendmail.cf file.

To begin the configuration process, we will utilize the talents of the Build script file. The following dialog demonstrates the steps required for building the .cf file:

stimpy $ pwd

From the base sendmail directory, we change to the cf/cf directory, which contains .mc and .cf files for a number of platforms. Next, you need to make a copy of the supplied .mc file as a local working copy. As shown in the dialog, we named it linux.mc, but you can give the file any name you want.

Finally, we execute the Build script, passing the name of the target file (which is linux.cf in this dialog).

The following listing shows the contents of the generic linux.mc file used to build the linux.cf file:

# This is a generic configuration file for Linux #

divert(0)dnl

VERSIONID(`$Id: generic-linux.mc,v 8.1 1999/09/24 22:48:05 gshapiro Exp $') OSTYPE(linux)dnl

MAILER(local)dnl MAILER(smtp)dnl

You must specify an OSTYPE so that platform-specific items are properly configured, such as the pathname for status files, flags required for the local mailer, and other items. Just be sure it is set to

linux.

MAILER(...) defines the mailers (delivery agents) you want sendmail to support. The local mailer is always included automatically. You should be aware that the MAILER(...) declarations should occur at the end of the configuration (.mc) file. Additionally, the MAILER(smtp) entry should always precede the

MAILER(uucp) entry, if applicable.

Table 8.3 lists the MAILER options.

Table 8.3. Options for MAILER

Option Description

local The local and prog mailers. You should always include these, unless you relay mail to another site.

smtp The Simple Mail Transfer Protocol (SMTP) mailer.

uucp The UNIX-to-UNIX Copy Program mailer.

usenet Usenet (network news) delivery.

fax Facsimile transmission.

pop Post Office Protocol.

procmail An interface to procmail.

mail11 The DECnet mail11 mailer. Useful only if you have the mail11 program.

phquery The phquery program.

cyrus The cyrus and cyrusbb mailers.

It is truly amazing to see the outcome from the previous build process. Look again at the contents of the linux.mc file, consisting of five instructional lines. The resulting linux.cf file consumes 1,165 lines of text! The following output shows snippets from various sections of the file:

# temporary file mode

Examine the last couple of lines - they look fairly cryptic. Actually, they are simple compared to some of the other rules (and definitions) found in the file.

Once the linux.cf file is ready, it needs to be copied to the /etc/mail directory. The following dialog demonstrates how to do this:

stimpy $ pwd

/tmp/sendmail-8.10.0/cf/cf

stimpy $ cp ./linux.cf /etc/mail/sendmail.cf stimpy $

The last step is to install the new sendmail executable. If you are replacing a current installation, be sure to save the binary, just in case the new version does not work as expected. The following dialog shows how to back up the current binary and then install the newly built binary:

stimpy $ pwd

/tmp/sendmail-8.10.0 stimpy $ which sendmail /usr/sbin/sendmail

stimpy $ cp /usr/sbin/sendmail /usr/sbin/sendmail.orig stimpy $ ./Build install

Making all in:

/mnt/tool/root/root/sm/sendmail-8.10.0/libsmutil

Configuration: pfx=, os=Linux, rel=2.2.13, rbase=2, rroot=2.2, arch=i586, sfx=

Making in ../obj.Linux.2.2.13.i586/libsmutil ...

...

Making in ../obj.Linux.2.2.13.i586/mailstats

make[1]: Entering directory `/mnt/tool/root/root/sm/sendmail-8.10.0/obj.Linux.2.

2.13.i586/mailstats'

install -c -o bin -g bin -m 555 mailstats /usr/sbin stimpy $ sendmail -d0.1 -bt < /dev/null

Version 8.10.0

Compiled with: LOG MATCHGECOS MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETUNIX NEWDB QUEUE SCANF SMTP USERDB XDEBUG

The output from the Build script spans many lines (about 100 on my system). Besides installing the executable, other chores are accomplished, such as the creation of directories and the installation of man pages. Notice the last command executed in the preceding dialog. We executed this in a previous dialog to test the build of the sendmail binary.

You are now ready to fire up the sendmail system.