Linux can be configured as a local mail server. This has been
tested on the standard Fedora core 7 Linux distro. Here Linux is configured for
relaying mails only in the local domain (example.com).
Server side Configuration
Server: Fedora core 7
Installed packages:
Sendmail server
1.
sendmail -8.14.1-4.2.fc7
& sendmail -cf -8.14.1-4.2.fc7 (packages)
Pop server
2.
dovecot ( imap/pop3) server
dovecot-1.0.0.11.fc7 (package
Mail Client
3.
Evolution/Thunderbird (for
Linux) standard package shipped with Red Hat/Fedora, outlook(for windows)
Or a web based client such as “squirrelmail”
can be used for accessing mails using web browser.
squirrelmail-1.4.10a-1.fc7 (package)
Other packages required for web based access
(squirrelmail only) of mails are:
Apache
php
All standard
Linux versions are shipped with apache (httpd) server and php.
Mail Server Configuration
Firstly we will make a local domain(example.com) on the linux
server so that we can create emails as username@example.com
We shall change the hostname of our Linux server to “mailserver” by
using the following command
# hostname mailserver
Also edit the file /etc/sysconfig/network to change the
HOSTNAME=mailserver.
# hostname
Would show the changed
hostname as “mailserver” ( For our Linux Mail server)
Domain creation
After this we need to create a local domain on Linux server. For
this we will edit the /etc/hosts file and add below entry to it below the”127.0.0.1
localhost.localdomain
localhost” line.
192.168.10.221
mailserver.example.com
mailserver
Save the file and exit. Upon exiting type the following command and
we should have our dns domain as example.com
# dnsdomainname
Would give output as
example.com
Hence we have created a local domain in Linux by the name of “ example.com”
After this add users on the Linux server using useradd command and
give then passwords. This shell login & password will be used for accessing
their e-mail accounts.
Next set an ip address for ur mail server,say(192.168.10.221) using
following command
# /sbin/ifconfig eth0 192.168.10.221
Sendmail configuration
Sendmail configuration is stored in /etc/mail directory which contains the sendmail
configuration fil as sendmail.cf. This file should not be directly edited using
vi editor. Instead m4 macro is used to configure this file using the
sendmail.mc file as follows.
sendmail.mc file is edited
and the using m4 macro is used to create the sendmail.cf file .
# m4
/etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Edit the sendmail.mc file
using vi editor and find this line in it.
DAEMON_OPTIONS (`Port=smtp,Addr=127.0.0.1 , Name=MTA’ ) dnl
The above line tells mail server to listen on only loopback
address(default setting for mailserver). Hence we should disable it to listen
on all available interfaces( i.e it should listen on eth0 interface also for
requests). Hence we will disable the above line by commenting it( placing “dnl”
in the beginning)
dnl DAEMON_OPTIONS
(`Port=smtp,Addr=127.0.0.1 , Name=MTA’ ) dnl
Next find the line with
LOCAL_DOMAIN and change it to “example.com” in place of localhost.localdomain
Now run the above m4 command
to create sendmail.cf file .
After this restart the sendmail service.
Dovecot configuration
Dovecot is an open source
IMAP & POP3 server. The configuration file is located in /etc directory as
dovecot.conf.
Edit the /etc/dovecot .conf file to make following changes in the
lines below:
Protocols = imap imaps pop3
pop3s
listen = * , [::]
disable_plaintext_auth =
no
ssl_disable = no
mail_location =
mbox:~/mail:INBOX=/var/mail/%u
pop3_uidl_format =
%08Xu%08Xv
auth default {
mechanisms
= plain
}
Save , exit and restart the dovecot.
Note: Dovecot automatically auto detects the user’s
mailbox in most cases (mail_location path given above need not specified in all
cases), but if Dovecot does not detect the mailbox for retrieving mails (see
/var/log/maillog), then we have to specify the mail location path as above.
Choose the mail location from the specified list of mail_location already in
the dovecot.conf file.
Testing the Dovecot
# telnet 192.168.10.221 pop3
Should greet you with
message “ Ok+ Dovecot ready”
Next login with user credentials as
# user chandan
Should greet you with “+Ok “
# pass chandan123
Should greet you with “+Ok Logged in”