Originally Published: Friday, 1 June 2001 Author: Earl Peters
Published to: learn_articles_firststep/General Page: 1/1 - [Printable]

Getting Started on Email Services with Linux

Linux.com volunteer Earl Peters delivers a comprehensive explanation of email services on Linux in a networked environment. This articles covers DNS and Sendmail in some detail, including their configuration files, and rounds out with a close look at setting up clients on Windows NT Workstation.

   Page 1 of 1  

Project Purpose and Overview:

I started this project primarily to learn how to use the Linux operating system in a networked environment. The purpose of this project was to create an e-mail server on Linux, and to have workstations retrieve mail from that server. For the email server I used Slackware Linux 7.1. I used Windows NT Workstation for the workstations. I only set up two different workstations, but you can set up others in the same way I have explained below. The server was given an IP address of, while the two workstations were and The gateway system to the Internet had an address of

This document will give you an idea of how to set up a DNS and configure most Windows clients to retrieve mail from a Linux based email server. I would recommend that you have a moderate skill level with the Linux operating system; otherwise some sections may get a little confusing.

Setting Up the DNS Services

First you need a way for your email clients to be able to see each other and more importantly see the mail server itself. There are a few methods you can use to do this, such as adding the correct static IP values to your hosts file in Microsoft Windows and Linux. I've decided to set up a DNS with Linux.

Before I went all-out with the DNS, I made a resolving, caching DNS to make sure I could get the DNS to see out to the Internet. Here's what the following files looked like (the names include the directory in which they should be located):

/etc/named.conf /*
* A simple BIND 8 configuration

options {
directory "/var/named";

zone "." {
type hint;
file "root.hints";

zone "0.0.127.in-addr.arpa" {
type master;
file "127.0.0";

The directory /var/named line tells named where to look for the files specified in this configuration file. The zone "." has two lines. The first line is the type line, which is set to hint. Hint instructs the DNS, if you can't find the address for something, look in the file specified. The second is the file line, which specifies in which file to look. The root.hints> file contains the names and addresses of the primary name servers the Internet uses. The zone 0.0.127.in-addr.arpa has similar lines to the zone "." section, the difference being that it specifies the type as master, which means our DNS is the master DNS for the 127.0.0 IP numbers.

/var/named/root.hints ;
; There might be opening comments here if you already have this file.
; If not don't worry.

This is the root.hints file. You can cut and paste this one if you would like, but the file does need to be updated every once in while. I will explain updating the file in the maintenance section at the bottom of this article.

/var/named/127.0.0 @ IN SOA mail.peters.com. root.mail.peters.com. (
2000070402 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
NS mail.peters.com.

1 PTR localhost.

The explanation for this file is a lengthy one, so I'm going to shorten it and tell you where to get a full explanation. (If you would like to know more I would recommend that you read the DNS HOWTO from the Linux Documentation Project.)

The first line has the mail.peters.com. entry. This specifies what machine this zone comes from. The other part of the first line, root.mail.peters.com, specifies who to send all DNS related email to: root@mail.peters.com. You should have your own email address in here if you are not the super user. The next few lines explain how many seconds to refresh, retry, expire, etc. The NS line specifies what machine is the name server for this zone (the 127.0.0 numbers). The PTR line says that is named localhost. Please note the periods at the end of the names of the machines; those are absolutely necessary! If they weren't there, the name would have peters.com added to the end of it (i.e. mail.peters.com.peters.com.), a mistake that will result in many different errors.

OK, there are only a few things left. Next we need to open the /etc/resolv.conf file. Make sure it looks something like this:

search peters.com

These entries tell the machine to try to resolve names through itself. When it comes to setting up the other machines, you will want to put in the actual IP number of this machine in instead of the Next, open your rc.inet2 file in the /etc/rc.d directory, scroll down until you see the section that is commented that would normally start "named". Uncomment those lines or add the following:

if [ -x ${NET}/named ]; then
echo -n " named"

Next, type "named" (without the quotes, of course). Now type in "tail /var/log/messages", and this will display the last few lines of the file. It should say something like "hint zone . loaded successfully", and "master zone "0.0.127.in-addr.arpa" loaded successfully". Basically, you don't want to see anything that remotely resembles an error message.


Now try pinging, lookups, and digging some addresses. I generally just do it with yahoo.com because I know what addresses I should get back. This is how the commands would look:

dig www.yahoo.com
nslookup www.yahoo.com
ping -c 10 www.yahoo.com

If it seems things are not working correctly, go and read the DNS HOWTO. There may have been updates to named since I've written this.

If this has all worked so far, congratulations! It's now time to make this a real DNS.

Add the following lines to your /etc/named.conf file:

zone "peters.com" {
type master;
file "peters.com";

zone "16.5.10.in-addr.arpa" {
type master;
file "10.5.16"

Now create the following files in the /var/named directory:

/var/named/peters.com $TTL 86400

@ IN SOA mail.peters.com. root.mail.peters.com. (
2000070603 ;serial
14400 ;refresh - 1 hours
3600 ;retry - 1 hour
864000 ;expire - 10 days
3600 ;minimum ttl - 1 hour

peters.com. A
; HINFO "Earl's DNS/Mail Server"
TXT "DNS/Mail Server"

mail A
MX 10 mail.peters.com.
TXT "Earl's DNS and Mail Server"
NS mail.peters.com.

ntclient1 A
TXT "NT 4.0 Workstation"
NS mail.peters.com.

/var/named/10.5.16 $TTL 86400
@ IN SOA peters.com. root.mail.peters.com. (
2000070601 ;serial
14400 ;refresh - 4 hours
3600 ;retry - 1 hour
864000 ;expire - 10 days
3600) ;minimum ttl - 1 hour

NS mail.peters.com.

12 PTR ntclient1.peters.com.
14 PTR mail.peters.com.

I'm going to try to explain this type of file a little more in depth. The first PTR line (12 PTR ntclient1.peters.com.) specifies that ntclient1.peters.com has an IP address of This is how that address is figured out: the zone (16.5.10.in-addr.apra) + PTR. So essentially that mean 10.5.16 + 12 = The address much match the one specified in the peters.com zone file.

Now that you've added those lines, and created the two files, you need to restart named. Do this by typing:

ps -aux | grep named

This will give you the process ID of named and the ps -aux command. Now you can restart the process with the following kill command:

kill -HUP Process ID of named

Now the full DNS should be up and running: Try doing an nslookup of mail.peters.com, you should get a response for it, not an error.

Configuring SENDMAIL

Sendmail is a program automatically installed when you install Linux onto a hard drive. With Slackware, Linux 7.1 the configuration files for sendmail is in the /etc/mail/ directory. If you would like to learn more on sendmail, please visit Sendmail.org. There are only a few files you need to edit.

# local info #


# my official domain name
# ... define this only if sendmail cannot automatically determine your domain


I had to add the Cwlocalhost line, the Fw/etc/mail/sendmail.cw line, and the Djpeters.com line so that sendmail would accept emails to a person with @peters.com at the end of their address. The sendmail.cw line is a list of aliases that sendmail will accept mail to, and send mail from. The file looked like this:

/etc/mail/sendmail.cw mail

With this file being set up the way it is, if someone sends mail to user@peters.com, the user will get that mail.

I also had to create a file called relay domains. That file is set up so that sendmail will not deliver mail from unfamiliar machines or domains, essentially preventing spam. This is how the file looked:

/etc/mail/relay-domains localhost

There is also a file called aliases in the /etc/mail directory. This file allows you to set up aliases for a user, or a group of users. The syntax for the line is: alias_name: real-user1, real-user2, etc. For example, if you add the line Office: epeters, mweber, root and you then send mail to office@peters.com the message will be delivered to epeters, mweber, and root.

Now that the DNS has been created and sendmail has been configured you're done with the Linux System. The next step is to configure the clients.

Configuring NT 4.0 Workstation to Read and Send Mail Through Linux

First step is to get the machines to use the DNS on the Linux Machine. If you're doing a fresh installation, then you can just add the IP address of the Linux Machine under the DNS tab when you're configuring the NIC (Network Interface Card). When NT is already installed. Follow these steps:

  • Hold down the ALT key and double click on Network Neighborhood.
  • Make sure the IP address tab is the one selected, and add the gateway's IP address in the Default Gateway field. In this case,
  • Click on the Protocols tab.
  • Select TCP/IP Protocol and click on the Properties button.
  • Click on the DNS tab.
  • Make sure the Host Name field has the proper name in it.
  • Add the domain name in the Domain field. In this case, peters.com.
  • In the DNS Service Search Order section click on add.
  • Enter the IP address of the Linux machine and click on add.
  • Click OK to go back to the Network Configuration window, then click OK on that window to save your changes.
  • Open up Internet Explorer and try to visit www.yahoo.com, it should work.

Assuming it's all working so far, next we have to set up the email program to go and get mail from the Linux email server.

Setting up Windows Messaging

  • Double Click on the Inbox icon on the desktop or run c:\Program Files\Windows NT\Windows Messaging/mlset32.exe.
  • When asked select yes to install Windows Messaging.
  • When it is done installing double click on the Inbox icon again.
  • When asked to select the information service you will use with Windows Messaging, select only the Internet mail option. Click next.
  • Next you will be asked how you connect to your Internet mail server, select network and click next.
  • Now it will ask the name or the IP address of the mail server, select IP address and enter the IP address of the mail server. In this case,
  • When asked the mode for transferring messages, select automatic.
  • Next you will be asked for an email address and a full name. Enter the email address for a user as user@peters.com (i.e. epeters@peters.com). Then put the users full name in the name field.
  • Now you will be asked about the mailbox name, and the password. Enter the users name in the mailbox field (i.e. epeters), and put that users password in the password field.
  • When asked about the personal address book file, and the personal folder file, use the defaults.
  • Click on finish.

If all worked correctly you should be in Windows Messaging, with 1 email from Microsoft.

Configuring Microsoft Outlook Express

Once in Outlook Express:

  • lick on the tools menu, and select accounts.
  • Click on the mail tab, then click on the add button.
  • A little sub menu will then pop out of the add button, select mail.
  • Enter you full name when the Your Name window opens, then click next.
  • Make sure the 'I already have an email address' section is selected. Then enter the email address you will use on the Linux email server (i.e. epeters@peters.com).
  • At the top of the next window, make sure you select POP3 for your incoming mail server.
  • In the two address fields below, put in the IP address of the Linux machine. In this case,
  • Now the Internet Mail Login Window opens up. Put the user name in the account name field (i.e. epeters), and put the users password in the password field. Click on remember password. Make sure the secure authentication option is not selected.
  • Next, click finish and you will be back at the Internet Accounts window. You may now click close.

The next time Outlook goes to get mail it will get it from the Linux server.


The only maintenance task you have to perform is updating you root.hints file (with the exception of adding new systems if you buy them). If you issue the dig command with no arguments, you will get a display of your current root.hints file. If you dig one of the nameservers, you will get an output that looks a lot like a root.hints file. So you can update your file by doing exactly that. This is the command to issue:

dig @e.root-servers.net . ns > root.hints.new

All you need to do is rename root.hints.new to root.hints and then restart your DNS server.

Closing Remarks

You may have found this tutorial is a little confusing. If so, the best suggestion I can give you is to read this a few times, then try implementing it. Developing this tutorial and learning Linux took me three months, and I know there is much more to be learned. This tutorial only scratches the surface of email, you can make an entire career out configuring email servers. If this is something you are serious about, I would definitely suggest learning as much as you can on it before thinking about starting.

   Page 1 of 1