How to Upgrade Sendmail to the latest version on CentOS

Recently I had to upgrade Sendmail version 8.13 to the latest version 8.15 on CentOS 5. If you are someone planning to upgrade Sendmail on your Linux machine, then here’s how you can do that.

To start with, you need to download the latest version (8.15, at the time of writing this article) from Sendmail’s official website.

Step 1: Backup existing sendmail binary and configuration files

First and foremost is to backup your current sendmail configuration files, startup scripts, sendmail binary, aliases, aliases database and the domain aliases (if any) as shown below:

Upgrading sendmail

[root@mailserver]#cp /usr/sbin/sendmail /usr/sbin/sendmail.old  (daemon)
[root@mailserver]#cp /etc/aliases /etc/aliases.old              (aliases file)
[root@mailserver]#cp /etc/aliases.db /etc/aliases.db.old        (aliases database file)
[root@mailserver]#cp /etc/sendmail.cf /etc/sendmail.cf.old      (configuration file)   
[root@mailserver]#cp /etc/sendmail.mc /etc/sendmail.mc.old      (configuration file)   
[root@mailserver]#cp /etc/sendmail.cw /etc/sendmail.cw.old      (domain aliases - if any)
[root@mailserver]#cp /etc/rc.d/sendmail /etc/rc.d/sendmail.old  (startup script)

Note: Sendmail binary location varies from operating system to operating system, but is usually in /usr/sbin or /usr/lib.

Step 2: Stop existing Sendmail daemon

Through your startup script, stop the sendmail daemon.

[root@mailserver]# /etc/init.d/sendmail stop
[or]
[root@mailserver]# service sendmail stop

Step 3: Obtain the latest source from sendmail.org and untar.

[root@mailserver]# wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.15.1.tar.gz
[root@mailserver]# gzip -cd bind-9.1.1.tar.gz | tar xvf -
[root@mailserver]# cd sendmail-8.15.1/
[root@mailserver sendmail-8.15.1]#

Step 4: Compile the source through the available Build script

From sendmail-8.15.1 directory, run “sh ./Build” to compile the source.

[root@mailserver sendmail-8.15.1]# sh ./Build

Step 5: Create a new Sendmail configuration file

If you want to use the existing configurations, then jump to step 6, else continue.

Create Sendmail.cf using m4 macro processor and copy to /etc/mail/

From the cf/cf/ directory, copy whichever .mc file best matches your system as sendmail.mc. Next, modify it accordingly as explained in cf/README.

[root@mailserver sendmail-8.15.1]# cd cf/cf
[root@mailserver cf]# cp generic-linux.mc sendmail.mc

Run the below command to create a new sendmail.cf using m4 macro processor.

[root@mailserver cf]#m4 ../m4/m4.cf sendmail.mc > sendmail.cf

[or]

[root@mailserver cf]# sh ./Build sendmail.cf
Using M4=/usr/bin/m4
make: `sendmail.cf' is up to date.
[root@mailserver cf]#

Now copy the generated sendmail.cf to /etc/mail/sendmail.cf

[root@mailserver cf]# cp sendmail.cf /etc/mail/sendmail.cf

Step 6: Use existing Sendmail configurations

Copy the /etc/mail/sendmail.mc file to your sendmail source cf directory.

[root@mailserver cf]# cp /etc/mail/sendmail.mc sendmail.mc

Create sendmail.cf using the existing sendmail.mc configurations as shown below:

[root@mailserver cf]#m4 ../m4/m4.cf sendmail.mc > sendmail.cf

[or]

[root@mailserver cf]# sh ./Build sendmail.cf
Using M4=/usr/bin/m4
make: `sendmail.cf' is up to date.
[root@mailserver cf]#

Now copy the generated sendmail.cf to /etc/mail/sendmail.cf

[root@mailserver cf]# cp sendmail.cf /etc/mail/sendmail.cf

Step 7: Install the Sendmail Binary

Install the binary created in step 4. This will install the binary to /usr/sbin, and installs the man pages as well.

[root@mailserver sendmail-8.15.1]#sh ./Build install

Step 8: Update the aliases Database

Update the aliases.db file by running newaliases

[root@mailserver sendmail-8.15.1]# newaliases
/etc/aliases: 102 aliases, longest 121 bytes, 3517 bytes total

Step 9: Start the Sendmail Daemon

Start the sendmail daemon as shown below:

[root@mailserver sendmail-8.15.1]# /etc/init.d/sendmail start
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]

Step 10: Verify the Sendmail version

With the help of telnet command shown below, verify the updated Sendmail version.

[root@mailserver sendmail-8.15.1]# telnet 0 25
Trying 0.0.0.0...
Connected to 0 (0.0.0.0).
Escape character is '^]'.
220 mailserver ESMTP Sendmail 8.15.1/8.15.1; Thu, 25 Jun 2015 13:43:25 +0530

Updated on September 3, 2017

Was this article helpful?

Related Articles

Leave a Comment