|
Linux Server How To - Install Sendmail Using Apt-get
Installing Sendmail Using Apt-get
Installing Sendmail using apt-get is an easy process that can be performed in around about one minute. Apt-get retrieves the selected packages from a source server on the internet and automatically installs the software you have selected for you, in this instance the Sendmail email server application. An internet connection is necessary for this process to be successfull. The commands documented here worked effectively on our Ubuntu Linux server and the majority of the information provided here should hold true for any Linux server using a distribution based on Debian.
To install Sendmail onto your Linux server simply log in and at the command line type sudo apt-get install sendmail -
john@ubuntu-linux-server:~$ sudo apt-get install sendmail
|
This will install Sendmail onto your Linux server and add the necessities to start sendmail as a service at system startup. The default installation will work effectively on the local machine but it may not accept mail from an external source. This is certainly true for our Ubuntu Linux server. This is because Sendmail may be configured to listen only on the loopback interface 127.0.0.1 and no other address assigned to the machine, a security feature designed to reduce spam and other mistreatment of your Linux mail server. This is easily changed if need be, bearing in mind that if you only wish to use sendmail locally then this configuration is ideal and should be left as it is.
We can consider the configuration of Sendmail to be divided between server and local configuration. The server configuration is mostly performed through sendmail.cf in the /etc/mail directory and covers most of the behavioural configuration of Sendmail such as the interfaces it listens on, default timeouts etc. Local configuration is controlled by other files in the /etc/mail directory such as local-host-names, relay-domains and virtusertable that allow you to configure specific domains and users that Sendmail will accept mail for. The lines that force Sendmail to bind to the loopback address only can be found in sendmail.cf and appear as below.
# SMTP daemon options
O DaemonPortOptions=Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1
O DaemonPortOptions=Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1
|
Simply removing Addr=127.0.0.1 from these two lines in sendmail.cf will resolve the problem but is not the preffered method by any means. Sendmail.cf should be rebuilt using the m4 general purpose macro processor rather than being modified directly.
When Sendmail was installed using apt-get it is very likely that two files were included in the installation and are most likely located in the /etc/mail directory. These two files, sendmail.mc and submit.mc, are used by the m4 processor to create the sendmail.cf file and submit.cf file and it is these that should be edited when any change to sendmail.cf or submit.cf is required. Simply open the .mc file you wish to edit with a text editor such as Vi or Pico, make your changes and save the file. Run either .mc files through m4 to create your new .cf file.
|
|
To make our mail server listen on addresses other than 127.0.0.1 edit sendmail.mc, locating the four lines below and removing the Addr= values shown below in red and the comma preceding them. Do not delete the whole line, just the parts in red.
FEATURE(`no_default_msa')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl
|
Use the m4 macro processor to build your new sendmail.cf which will be called newsendmail.cf by typing-
john@ubuntu-linux-server:~$sudo m4 sendmail.mc > newsendmail.cf
|
Make a backup of the distributions sendmail.cf by typing-
john@ubuntu-linux-server:~$sudo cp sendmail.cf sendmail.cf.dist
|
And then copy the new sendmail.cf to replace the distributions-
john@ubuntu-linux-server:~$sudo cp newsendmail.cf sendmail.cf
|
Restart Sendmail to load the new configuration-
john@ubuntu-linux-server:~$sudo service sendmail restart
|
|
|