by March 1, 2005 0 comments



We assume that you have a mail server on the Internet, and that you are setting up a local mail server on the intranet to route local mail. That is, mail to a user on the network will remain local, and will not reach the Internet mail server. For the purpose of this article, we have used the following settings.

IP address of local e-mail server running PCQLinux 2005: 192.168.1.4
Hostname of local mail Server:
intranetmail.cybermedia.co.in
Internet mail server:
mail.cybermedia.co.in
E-mail domain:
cybermedia.co.in
Gateway (to Internet):
192.168.1.1

Make sure to substitute our settings with yours throughout the article.

Local mail routing

We will do the set up in such a way that mail destined to non-existent (on the intranet server) accounts, but belonging to the same domain, are sent to the Internet mail server. For example, suppose users Shekhar and Anoop are sitting in the Delhi office on the local intranet network (mentioned above) and Sanjay is sitting in the Mumbai office. Their e-mail addresses are
shekhar@cybermedia.co.inanoop@cybermedia.co.in 
and sanjay@cybermedia.co.in
While Shekhar and Anoop have user accounts on the intranet e-mail server, Sanjay does not. If Shekhar sends an e-mail to Anoop, it will remain on the local intranet server at 192.168.1.4. But, if he sends an e-mail to
sanjay@cybermedia.co.in,  it is sent to the Internet e-mail server (ie, mail.cybermedia.co.in).

Set up the prerequisites

While installing PCQLinux 2005 on the intranet server machine, go for a Groupware installation type. At the Package Selection screen, click on details besides Mail Server and select Postfix. Select (check) Security under PCQLinux Specials. Also select system-switch-mail, which can be found by clicking on details besides Server Configuration Tools.

Create user accounts for e-mail users on your private network on the PCQLinux machine (192.168.1.4). You can create user accounts using the useradd <user-name> and passwords using passwd <user-name> commands. Alternatively, you can do it graphically through Webmin. For this, launch Webmin and browse to System>User and Groups and click on ‘Create a new user’. Here, provide all details and say Edit. For Shell, select /bin/bash from the drop-down menu. Then issue the system-switch-mail command and select Postfix. 

Set up Postfix and POP

In Webmin, click on Servers>Postfix Configuration and on General Options. For ‘What domain to use for outbound mail’, select the Radio button next to the text field and fill in cybermedia.co.in. For ‘What domains to receive mails for’, fill in cybermedia.co.in. Scroll down, and for ‘Network interfaces for receiving mail’, select All. For ‘Local internet domain name’, click on the Radio button and again type in cybermedia.co.in. Click on Save and Apply.

On the ‘Postfix Configuration’ page, click on ‘Address Rewriting and Masquerading’. For Address Masquerading, click on the Radio button and type in cybermedia.co.in in the text field. Click on Save and Apply.

To set up local mail routing, click on Local Delivery icon on the main page. Scroll down and for ‘Optional transport for unknown recipients’, click on the Radio button and fill in
smtp:mail.cybermedia.co.in. Here, mail.cybermedia.co.in is the name of the Internet e-mail server. Using a text editor, open the file named main.cf found in the directory /etc/postfix in a text editor and append the following line to it:

local_recipient_maps =

Note that there is nothing after the equal to (=) sign. Back to Webmin, click on ‘Save and Apply’ on the ‘Local delivery’ page.

For configuring PoP, if not already installed, install the RPM imap-2002d-3.i386.rpm from PCQLinux CD3. Open a terminal window within X and issue the ntsysv command. From the listed services, select ipop3 and issue the command service xinetd restart.

Fetching mail from the Internet server

When people from outside your network, send or reply to e-mail from local users, they will be stored on the Internet e-mail server. This is because we haven’t hosted our local mail server on the Internet, which will need to have a public Internet IP and DNS MX entry. Hence, we need to fetch mail from the Internet e-mail server to the local e-mail server, so that when local users connect to the intranet server using their e-mail clients they get e-mail from the Internet as well. This is done using Fetchmail. If not already installed, install the RPM named fetchmail-6.2.5-6.i386.rpm from PCQLinux 2005 CD1.

In Webmin, browse to Servers>Fetchmail Mail Retrieval. Suppose you want to fetch mail for a user named Shekhar. Click on the button labeled ‘…’. This will pop-up a window showing all user accounts.

Click on the user name shekhar. Click on Add Fetchmail Server for user. For ‘Mail server to contact ‘ click on the Radio button near the empty text box. Fill in the following details:

Server Name: intranetmail.cybermedia.co.in
Mail Server to contact: mail.cybermedia.co.in
Remote user: anoop
Remote password: xxxxx
Local user: anoop@cybermedia.co.in 

The remote user and password are the login and password of the user on the Internet mail server. For Protocol select POP3 or IMAP depending on the one supported by your Internet mail server. Click on Create. Similarly, key in details for other e-mail users.

Set up anti-spam and anti-virus

First open the file named amavisd.conf from /etc directory and find the line saying ‘$mydomain = example.com’ and change example.com to cybermedia.co.in (the E-Mail domain). Scroll down to the line that says,

[‘Clam Antivirus-clamd’,

and substitute /var/amavis/clamd with /var/run/clamav/clamd.sock in the line below it. Also remove the preceding # (hash) from each line. When done, the section should look as follows.

[‘Clam Antivirus-clamd’,
\&ask_daemon, [“CONTSCAN {}\n”, ‘/var/run/clamav/clamd.sock’],
qr/\bOK$/, qr/\bFOUND$/,
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],

Next, open the file master.cf found in the directory /etc/postfix in a text editor. Find the line which says:

smtp inet n – n – – smtpd

and append ‘-o content_filter=smtp-amavis:[127.0.0.1]:10024’ to this line

Append the following lines to the end of the file,

smtp-amavis unix – – n – 2 smtp
127.0.0.1:10025 inet n – n – – smtpd

Save it and open a file, clamd.conf found in /etc directory in a text editor. Remove the comment mark (#) for the line ‘LocalSocket /var/run/clamav/clamd.sock’ and comment out (by prefixing a #), the following lines:

TCPSocket 3310
TCPAddr 127.0.0.1

With the configuration in place, we are ready to deploy our E-Mail system. Start Postfix server by typing the
service postfix start command. Start Amavisd and Clam Antivirus by typing service amavisd start and then service clamd start. To update Clam with the latest virus definitions, issue the freshclam command. Point the e-mail clients on the network machines to the IP address of the Linux machine.

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

<