Linux Mail Server Configuration
Essay Preview: Linux Mail Server Configuration
Report this essay
Email is an important part of any Web site you create. In a home environment, a free web based email service may be sufficient, but if you are running a business, then a dedicated mail server will probably be required.

This chapter will show you how to use sendmail to create a mail server that will relay your mail to a remote users mailbox or incoming mail to a local mail box. Youll also learn how to retrieve and send mail via your mail server using a with mail client such as Outlook Express or Evolution.

Configuring Sendmail
One of the tasks in setting up DNS for your domain ( is to use the MX record in the configuration zone file to state the hostname of the server that will handle the mail for the domain. The most popular Unix mail transport agent is sendmail, but others, such as postfix and qmail, are also gaining popularity with Linux. The steps used to convert a Linux box into a sendmail mail server will be explained here.

How Sendmail Works
As stated before, sendmail can handle both incoming and outgoing mail for your domain. Take a closer look.
Incoming Mail
Usually each user in your home has a regular Linux account on your mail server. Mail sent to each of these users ([email protected]) eventually arrives at your mail server and sendmail then processes it and deposits it in the mailbox file of the users Linux account.

Mail isnt actually sent directly to the users PC. Users retrieve their mail from the mail server using client software, such as Microsofts Outlook or Outlook Express, that supports either the POP or IMAP mail retrieval protocols.

Linux users logged into the mail server can read their mail directly using a text-based client, such as mail, or a GUI client, such as Evolution. Linux workstation users can use the same programs to access their mail remotely.

Outgoing Mail
The process is different when sending mail via the mail server. PC and Linux workstation users configure their e-mail software to make the mail server their outbound SMTP mail server.

If the mail is destined for a local user in the domain, then sendmail places the message in that persons mailbox so that they can retrieve it using one of the methods above.

If the mail is being sent to another domain, sendmail first uses DNS to get the MX record for the other domain. It then attempts to relay the mail to the appropriate destination mail server using the Simple Mail Transport Protocol (SMTP). One of the main advantages of mail relaying is that when a PC user A sends mail to user B on the Internet, the PC of user A can delegate the SMTP processing to the mail server.

Note: If mail relaying is not configured properly, then your mail server could be commandeered to relay spam. Simple sendmail security will be covered later.

Sendmail Macros
When mail passes through a sendmail server the mail routing information in its header is analyzed, and sometimes modified, according to the desires of the systems administrator. Using a series of highly complicated regular expressions listed in the /etc/mail/ file, sendmail inspects this header and then acts accordingly.

In recognition of the complexity of the /etc/mail/ file, a much simpler file named /etc/ was created, and it contains more understandable instructions for systems administrators to use. These are then interpreted by a number of macro routines to create the file. After editing, you must always run the macros and restart sendmail for the changes to take effect.

Each directive starts with a keyword, such as DOMAIN, FEATURE, or OSTYPE, followed by a subdirective and in some cases arguments. A typical example is.

FEATURE(`virtusertable,`hash -o /etc/mail/virtusertable.db)dnl
The keywords usually define a subdirectory in the /usr/share/sendmail-cf file in which the macro may be found and the subdirective is usually the name of the macro file itself. So in the example, the macro name is /usr/share/sendmail-cf/feature/virtusertable.m4, and the instruction ` hash -o /etc/mail/virtusertable.db is being passed to it.

Notice that sendmail is sensitive to the quotation marks used in the m4 macro directives. They open with a grave mark and end with a single quote.
Some keywords, such as define for the definition of certain sendmail variables and MASQUERADE_DOMAIN, have no corresponding directories with matching macro files. The macros in the /usr/share/sendmail-cf/m4 directory deal with these.

Once you finish editing the file, you can then execute the make command while in the /etc/mail directory to regenerate the new file.

[root@bigboy tmp]# cd /etc/mail
[root@bigboy mail]# make
If there have been no changes to the files in /etc/mail since the last time make was run, then youll get an error like this:
[root@bigboy mail]# make
make: Nothing to be done for `all.
[root@bigboy mail]#
The make command actually generates the file using the m4 command. The m4 usage is simple, you just specify the name of the macro file as the argument, in this case, and redirect the output, which would normally go to the screen, to the file with the “>” redirector symbol.

# m4 /etc/mail/ > /etc/mail/
Ill discuss many of the features of the file later in the chapter.
Installing Sendmail
Most RedHat and Fedora Linux software products are available in the RPM format. You will need to make sure that the sendmail, sendmail-cf, and m4 software RPMs are installed. (Chapter

Get Your Essay

Cite this page

Dedicated Mail Server And Mail Server. (April 2, 2021). Retrieved from