E-mail server section
E-mail server setup
What we want to accomplish here is the setup of a mail server with the following properties:
- can serve multiple mail domains
- can relay mail for other domains to other mail servers
- can have one or more mailboxes per domain
- users of these mailboxes can be virtual (do not need to have a Linux user account)
- can have multiple aliases per mailbox
- can forward mail for certain aliases to multiple mailboxes
For this type of mail server setup, we owe a great thankyou to Christoph Haas
Preparation
We'll assume that the server currently has no mailserver installed, at least no other than the default exim mailserver. Furthermore, the server is already fitted with MySQL, and this database is running without problems.
The hostname of the server must be set correctly, so that hostname -f returns a valid DNS name, like lighthouse.saruman.biz.. It might also be an internal name like lighthouse.saruman.lan. but that will require us to give extra attention to the name under which Postfix will contact its collegues on the Internet. Also, the server can correctly [Networking_section#DNS_resolution_under_Debian | resolve DNS names] like www.debian.org, preferably by running it's own caching DNS server.
The server is kept on the correct date and time using NTP, TCP port 25 is open on the server, the ISP will allow connections from Internet to this port, and if there's a firewall running on this server, then it has port 25 open so as to not block incoming e-mail.
Software installation
As a first step, we use apt or aptitude to make sure that our server is up-to-date. Then we can install the necessary software packages. Under Debian 5.0 "Lenny", the (single) packages is:
- postfix, the mail server itself - this includes the "virtual package" postfix-tls, that we want to use to secure connections to Postfix with the TLS protocol
At the same time we can - and must - purge the following packages:
- exim4
- exim4-base
- exim4-daemon-light
- exim4-config
In aptitude, only press "go" when you've marked all four of these packages "purge", or you cannot install postfix.
When installing the postfix package, the Debian installer script will ask you several questions, which you can answer like this:
- General type of mail configuration: Internet site
- System mail name: the FQDN of the mail server that you've verified in the previous section. Note that the script will try to guess the DNS name, but that might yield a DNS name with a trailing dot. That is technically correct, but the installation script will barf. Remove the trailing dot before hitting <enter>!
- Postmaster mail address: the address that all mail should go to that is addressed to "root" and "postmaster".
- Domain list: give the list of all domains that the machine can consider itself the FINAL destination for. This should at a minimum include an empty value, "localhost" and the FQDN of the machine itself (no trailing dots!); however, if you're running your own mail domain, you can also add that (e.g. "saruman.biz"). Thus, the list could look like this:
saruman.biz, lighthouse.saruman.lan, localhost.saruman.lan, , localhost
- Force synchronous updates? We think that's not necessary, but please read the question and decide for yourself
- Local networks: something like 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.67.0/24 (the default, augmented with your local IP range)
- Mailbox size limits: you can give postfix a limit in bytes, but we're going to use one single big mailbox for all users, so we cannot let Postfix guard it. Leave it at 0 (zero) so we don't have a size limit.
- Character for local address extension: we leave it at +
- Internet protocols to use: currently we don't have IPv6 support, so there's no sense in letting Postfix try to serve IPv6. We choose ipv4 only.
With the above data, the Debian install script for Postfix can do its job and configure Postfix with some basic settings.
Now that Postfix is installed, we can install some dependent packages (we could install them in the same run, but if anything goes amiss with the postfix installation, then these packages are going to remain unconfigured as well):
- postfix-doc, the accompanying documentation;
- postfix-mysql, necessary to have Postfix talk to our MySQL server;
- postfix-pcre to be able to parse regular expressions, which which we can combat spam.