Howto setup a mail server
Introduction
When you set a mail system you minimaly need 2 things: a smtp server and a pop server.
A Simple Mail Transfer Protocol (SMTP) server will relay mails, meaning it receives them AND sends them also. On your Freesco, you will need to tell exim that it can only serve your.dyndns.org mails or, otherwise, you'll have a public mail relayer and spammers just loves that. Knowing it is serving for that domain, when it receives mail for whateva@your.dyndns.org, it will send it to a local user on Freesco. So you send mail to your smtp server, it will forward it to the recipients smtp server. smtp server receive a mail for a local user and put the message in his mailbox.
Now, when your mail gets in your mailbox, you want to be able to retreive it from a remote machine, right? Well, a Post Office Protocol server permits you to do just that. Using a username/password (usualy the same as when you log to the terminal), you connect to the pop server with a mail client and the server will send you your mail.
Note that you can telnet to both servers. telnet your.dyndns.org , 25 for the smtp and 110 for the pop.
See telnet smtp and telnet pop for a list of commands.
This is the minimalistic setup. Over that, you can add have a local Mail User Agent (MUA) to send and recieve mail from within Freesco. There is Fetchmail to retreive the content of remote mailboxs into your local system. There is fowarding. There are a couple of things.
You'll have more then you bargained for :p
To summ up
Configurations could include:
- Exim
- Exim + Popa3d
- Fetchmail + Exim + Popa3d.
What you need to do is understand how the software packages rely on one another:
EXIM + POPA3D = 'MAIL SERVER' and how one won't work without the other.
FOR THE NEWBIES like myself that need to have some things spelled out. Popa3d (or Qpopper) like mentioned previously is a POP3 SERVER, another way to think of this, is, it is the communication WIRE between EXIM THE MAIL SERVER and an email client.
EXIM -------POPA3D (the communication wire)------- email clients
Steps to get the mail server up and running
Download and install the EXIM package
There has been a problem reported with this package that can cause the system to hang and eventually stop working if you have deleted the root account and replaced it by another account with root privileges. You should not install this package (exim 4.50) in this case.
IMPORTANT : If you plan on using also the perl package (for spamassassin) you must install perl before exim. Otherwise it will not work.
Exim
Exim is a message transfer agent (MTA) with well-documented, extensive features. It handles the sending of local and remote mail. There is a great deal of flexibility in the way mail can be routed, and there are extensive facilities for checking incoming mail.
Exiscan
Exiscan is a patch against exim version 4.x, now included in the source code in version 4.50, providing support for content scanning in email messages received by exim. It works after the sending client has completed the SMTP data phase and waits for an answer from the server. Messages containing unwanted content can be rejected at that stage, so the job of generating a bounce message is the job of the sending host.
Four different scanning facilities are supported:
- antivirus
- antispam
- regular expressions
- file extensions
(see below “extra packages”)
The latest exim version (4.50) can be found atFreescosoft.
For more info about this package look at this post in the forum. To install it, you can simply use :
pkg -i -/exim_4.50_phbc50
from a command line prompt.
Configure it
To configure exim you need to edit the main config file /etc/exim.conf.
Before you do, first make a backup of the original config file; before you start editing with your favourite text editor (vi, joe, mc, teddy).
To edit the file you can simply type :
edit /etc/exim.conf
(followed by
There are four important points not to miss in the config file :
1. The primary hostname
Scroll down the file and search for this line :
primary_hostname = router.inet
This indicates what emails going out of your box will have as a domain.
You need to replace router.inet and put instead your dynamic hostname. This can be a domain obtained from a dynamic DNS service like dyndns or no-ip.
In my case my hostname is freesco.zapto.org so I put it like this :
primary_hostname = freesco.zapto.org
2.The local domain(s)
Go down a litlle and find this line:
domainlist local_domains = localhost : your.dynamic.hostname : router.inet
You have to add every domain that you want exim to respond to in this line.
· router.inet is the hostname and domain name of freesco so you can leave it (or change it to your setup hostname and domain).
· localhost : DO NOT remove this one, this is so that exim recognizes mails send from within FREESCO
· your.dynamic.hostname must be replaced with the external domain name of your box, in order for exim to receive mails for user@your.dynamic.hostname.
The items should be separated with a ':' (column), so the list results in (in my example):
domainlist local_domains = localhost : freesco.zapto.org : router.inet
3. The domains for which we relay
Shortly after look for this line:
domainlist relay_to_domains = your.dynamic.hostname : router.inet
Here you should replace your.dynamic.hostname with your dynamic hostname, resulting in something like :
domainlist relay_to_domains = freesco.zapto.org : router.inet
R: eventually change router.inet to match your FREESCO setup hostname and domain.
4. The hosts for which we authorize to relay without authentication
Finally, a few lines after look for this line :
hostlist relay_from_hosts = 127.0.0.1 : your.dynamic.hostname
It is usefull to put your LAN IP RANGE(s) here if you want to send mail out from any account, without needing to use SMTP AUTH (having to use a Freesco name and password to be able to send mail).
Simply replace your.dynamic.hostname with your LAN IP RANGE(s) (but leave the 127.0.0.1 !), separated by ':' (column).
R: put a /16 at the end of the range.
If for instance you use 192.168.0.x addresses in your network, it should look like :
hostlist relay_from_hosts = 127.0.0.1 : 192.168.0.0/16
Ok!, now save the config file with
rc_exim restart
followed by
Install a pop3 server
Popa3d
Popa3d is a tiny POP3 daemon designed with security as the primary goal. It's reliable and efficient, small and perfectly fits for regular use (including delivering a large number of messages).
Popa3d is available here
Qpopper
Qpopper is the most widely-used server for the POP3 protocol (this allows users to access their mail using any POP3 client). Qpopper supports the latest standards, and includes a large number of optional features. Qpopper is normally used with standard UNIX mail transfer and delivery agents such as sendmail or smail.
Qpopper supports Mysql with the mysql-4.1.7a-lighting package.
It is available here
There is no configuration needed, Popa3d or Qpopper both work “out of the box” with exim.
Test the server with telnet
You can test if exim works using telnet.
Log in as root and type:
telnet localhost 25
Since FREESCO version 0.3.4, the telnet client has been replaced by an ssh client, so another solution is to do this from another computer on the lan using :
telnet router.ip.address 25
router.ip.address being the IP address of FREESCO
at the prompt you should get something like :
220 freesco.zapto.org ESMTP Exim 4.50 Sat, 04 Feb 2006 03:12:34 +0000
then, type
quit
and try
telnet router.ip.address 110
here also replace router.ip.address by the IP address of FREESCO. it should yield :
+OK Qpopper (version 4.0.5) at router.inet starting.
or just
+OK
for popa3d.
Then type
quit
to exit
Add users
You must add users to FREESCO, this is essential as exim uses the user password list in freesco to allow connections unto itself.
The thing that you need to understand about exim is the fact that user accounts = email accounts
The command to add a user in FREESCO is :
useradd username
where username is the name you want for the user.
Give those users a HOME directory, or it won't work.
Add as many users as you want mailboxes.
Aliases
IMPORTANT :
You must set an aliase for the root user in /etc/aliases, because for safety reasons no mails will be delivered to root. This reason may cause frozen messages.
Here is how you can do :
Edit /etc/aliases with :
edit /etc/aliases
Search for these lines :
# root aliase : change the next setting to a valid email user:
root: your_user
and change your_user with an existing email user on your system.
R: there is a real [tab] between ”:” and the “username”.
SET UP email client
You need to add identities to your email client corresponding to the new users added to FREESCO. Then set the outgoing mail server and incoming mail server in your identities configurations to use your FREESCO domain (your dyndns/no-ip address).
An example of my email address is webmaster@freesco.zapto.org
Try sending an email using one identity and receive it using another identity. It should work like a charm.
Now you can receive and send mails using your FREESCO box!
Advanced…
For more advanced things to do with your new email server, keep reading…

Niciun comentariu:
Trimiteți un comentariu