Advertisment

Setting Up a Mail Server

author-image
PCQ Bureau
New Update

Here, we’ll set up sendmail on the Intranet machine. This is the machine with which all the users are in direct contact for mail delivery, Internet access, and internal service requirements. The Intranet box has user accounts for our domain and gives out any external mail to the gateway box. It also uses the gateway box to send out any external traffic to the Internet.

Advertisment

Setting up sendmail

Configuration of sendmail on the Intranet box is much simpler than what we did for the gateway box (See Configuring the Gateway Machine, page 109). This is because all internal mail is delivered immediately and all external mail is handed over to the gateway box for further delivery.

However, we still have to make some changes to the default behavior of sendmail to make it do the following.

Advertisment
  • Give all outgoing mail to the gateway box.
  • Configure it to relay mail from the 192.168.1.0 network only.
  • Configure it to accept mail for our domain pcqlinux.com locally and not to send it out to the Internet.
  • Configure POP3 and IMAP servers so that users can access their mailboxes.

Configuring sendmail

We’ll use the m4 macros to generate the sendmail.cf file as we did for the gateway machine.



Open /etc/mail/sendmail.mc and add the following macros to it.

Advertisment

define(`confDOMAIN_NAME’, `pcqlinux.com’)



This tells sendmail the domain name to use for our setup.

Sendmail will send all mail which is not to be delivered locally to the machine specified as a smart host. We need to give out all external mail to the gateway machine, for which we need this line:

define(`SMART_HOST’, `gateway.pcqlinux.com’)

Advertisment

We need to masquerade all outgoing mail to be coming from the domain pcqlinux.com. Add this line to sendmail.mc for this purpose.

MASQUERADE_AS(`pcqlinux.com’)





By default, sendmail is configured to listen on the lo interface only. We will change this as we did on the gateway box.
Find this entry

Advertisment

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)

and add two lines with the IP address of the internal and the external interface on the Intranet box.

# SMTP daemon options

Advertisment

O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA



O DaemonPortOptions=Port=smtp,Addr=192.168.1.1, Name=MTA


O DaemonPortOptions=Port=smtp,Addr=192.168.0.2, Name=MTA


We are done with the changes in this file. Now we need to generate our new sendmail.cf file. Run


m4 /etc/mail/sendmail.mc > /etc/sendmail.cf


Now open /etc/mail/local-host-names. Put your domain name on a line by itself for which you want to accept mail. That is, pcqlinux.com

Sendmail by default will not allow relaying mail through it. So, open the file /etc/mail/access and put a line which says



192.168.1 RELAY

Advertisment

This tells sendmail to RELAY any mail coming from the network 192.168.1.0. If you want to allow individual machines to do this, you can specify multiple RELAY entries with the IP of the machine instead of the network.

Restart sendmail by issuing



service sendmail restart

Create local user accounts, point your mail client to send mail using this machine, and try sending a mail from any machine on the network to any of the local users using the format @example.com. The mail should be delivered immediately. Now try sending a mail to any outbound host like Hotmail.com. The mail should be sent to the gateway box for delivery. You can check the queued mail using the ‘mailq’ command on the gateway box.

Remember that even for local delivery to work properly, you need a proper DNS configured on your local network.

This sets up sendmail to handle all your outgoing mail and the internal mail traffic.

Configuring POP3 and IMAP

Mail will be available to users in their individual mailboxes, but we need to install a POP3 or IMAP server so that users can access the mailbox from any mail client on their desktop. Let’s start with

IMAP.

First, check if the imap package is installed.

rpm -q imap

If it is not installed, install it from the /Redhat/RPMS directory on PCQ Linux CD 2 using



rpm -ivh imap-2000-9.i386.rpm

Now run ntsysv and enable the IMAP and POP3 services. Restart xinetd using



service xinetd restart

Users on your local network should now be able to access their mail using POP3 and IMAP from the Intranet box.

Vaibhav Sharma is a network consultant

with Exocore Consulting

Advertisment