Preparing the system
If your server was upgraded from "Etch"
If your server has been upgraded from a former Debian 4.0 "Etch" installation then you may need to fix two files. First make sure that your /etc/hostname contains the host name without the domain part. It does that on Lenny by default but if you are upgrading from a previous "Etch" installation then this may be wrong. The file /etc/mailname is supposed to contain the fully-qualified host name with the domain part.
Your /etc/hosts may also need to be fixed. Run hostname --fqdn and see if you get the fully-qualified hostname. If you just get the hostname without the domain please check that your /etc/hosts file has the fully-qualified hostname first in the list.
Wrong:
20.30.40.50 mailserver42 mailserver42.example.com
Right:
20.30.40.50 mailserver42.example.com mailserver42
Installing packages
Then begin by installing Postfix with MySQL backend support:
$> aptitude install postfix-mysql
This will also install the postfix package automatically. Exim (the default mail service installed with a fresh installation) will be removed. When asked for the general type of configuration choose "Internet Site". Answer the question for the "System mail name" by entering the fully qualified hostname of your system.
Run this line on the system to install the MySQL server:
$> aptitude install mysql-server
Note: You can run MySQL server on the same system as your actual mail service - but don't have to. The mail server can communicate with the MySQL server via TCP networking. During the installation you will get asked for the password of a newly created "root" user. This is not your system administrators login account but a special user to access the MySQL server. Choose any password you want and write it down. And another warning: during the installation a MySQL user account called "debian-sys-maint" will be created with a random password. The password is stored in the /etc/mysql/debian.cnf file. Do not touch this file or change the user's password in the database or you won't be able to stop or start the MySQL service any more.
You will want to offer POP3 and IMAP services to your users so you need to install Dovecot's services:
$> aptitude install dovecot-pop3d dovecot-imapd
Some of the packages needed to scan for virus-infected attachments are not "free enough" to be included in Debian's main section (e.g. "unrar" or "lha"). If you want to install them you first need to add the non-free section to your Debian mirrors in the /etc/apt/sources.list file. You usually just need to add "non-free" to your existing mirror lines for the Debian archive like this:
deb http://ftp.debian.org/debian/ lenny main non-free
and run
$> aptitude update
to update your package cache with the list of "non-free" packages.
It's a good service to your users to filter out spam and viruses for them. AMaViS is doing a good job here to detect unwanted emails:
$> aptitude install amavisd-new spamassassin clamav-daemon lha arj \
unrar zoo nomarch cpio lzop cabextract
AMaViS is now installed with a number of suggested packages to scan attachments for viruses and detect spam.
If you intend to offer a webmail service I can recommend the Squirrelmail package. It will automatically install the Apache web server if you do not yet have one installed. Type:
$> aptitude install squirrelmail
As your control information for Postfix will be stored in a MySQL database you may want to install the PhpMyAdmin software that allows you to manage the database and its data in your web browser:
$> aptitude install phpmyadmin
(If you get asked which web server to configure you will probably want to choose "apache2".)
The console-based mutt email client lets you read mail from mailboxes directly from the hard disk. It will be helpful for testing the configuration. And it's even a very powerful IMAP email client that many people use as their main mail program. Maybe you'll start to like it, too. You should install it at least for testing:
$> aptitude install mutt
Now all basic packages are installed and it's time to prepare the database in the next chapter.
The contents of this web site is Copyright © 2000-2011 Christoph Haas - Impressum/Imprints - Donations welcome
Drupal theme by Kiwi Themes.
18 comments
aptitude or apt-get?
Hello,
First of all thanks for this great tutorial!
I am wondering if there is any difference if I use apt-get instead of aptitude.. any ideas?
Thanks,
Charalampos Pournaris
aptitude
Hi, Charalampos...
apt-get and aptitude are pretty similar. aptitude (without using parameters) has a very sophisticated curses-based interface and is better in keeping your system clean by keeping better track of which packages got installed automatically.
Christoph
hostname and mailname files
hello,
I am using the Debian Lenny provided by linode.com and I don't find the files:
/etc/hostname and /etc/mailname
but hostname --fqdn
returns the fully-qualified hostname.
Should I create the two files with the right data in them?
Thanks
what about saslauthd
I read from other tutorials that saslauthd is also installed. Why isn't it here in this tutorial?
Could also explain the difference between Secure connection and Secure Autentication? Following this tutorial, I can have secure connection working properly but no secure authentication.
I believe that we discussed
I believe that we discussed this on IRC already. :)
Secure connection: TLS right from the start of the connection (e.g. SMTP on TCP port 465 instead of 25)
Secure authentication: Unencrypted from the start but then switching to TLS after a STARTTLS command
saslauthd is harder to configure. If you are using Dovecot it's much easier to set up SMTP authentication.
Christoph
With "Secure authentication"
With "Secure authentication" will it encrypt my username/password?
Yup
Yup
Hostname / Domainname Confusion
I have my mailserver on my LAN, ports 25 and 465 get forwarded to its private IP by the firewall-router.
/etc/hostname = mx
/etc/hosts reads "192.168.3.20 mx.m.lan mx"
/etc/mailname = mailserver.domain.tld
mailserver.domain.tld is set up as MX10 for domain.tld and the other domains it will be hosting, the reverse DNS entry for the used public IP is mailserver.domain.tld, and there is mx.domain.tld as CNAME for mailserver.domain.tld as well.
The setup seems to be working, except that the X-headers contain the local host/domainname:
X-spam-checker-version: SpamAssassin 3.2.5 (2008-06-10) on mx.m.lan
X-virus-scanned: clamav-milter 0.95.2 at mx
I am using spamass-milter and clamav-milter in my testsetup, and I could not find a way to change that.
Can that cause any problems? I am not comfortable with having the local FQDN exposed in sent emails.
I guess, the solution is to change the entry in /etc/hosts, but I am not sure, if there is any unwanted sideeffect. I mean, is there any downside in changing the local host/domainname in /etc/hostname or /etc/hosts to mx.domain.tld, since the machine is on the LAN and does not have a public IP itself?
AFAIK the entries in /etc/hosts and /etc/hostname should have no direct influence when sending and receiving emails. When postfix sends an email, it only comes down to the entry in /etc/mailname and that that one matches the reverse DNS entry, right? And for postfix receiving emails it only comes down to the MX DNS entry, right?
Is there any downside in having the FQDN in /etc/hostname? Because the OpenVZ container setup script still sets it that way.
myhostname vs. smtp_helo_name
The assumption was, that /etc/mailname is used by all means, but that's not entirely right, because the Debian postfix-setup-script sets something different for myhostname, depending on your /etc/hosts and /etc/hostname setup, and then myhostname gets used for about everything import, even smtp_helo_name.
The new assumption is, that the hostname and /etc/hosts setup does not matter at all for sending emails, as long as smtp_helo_name = (/etc/mailname) = PTR & A entry for the used IP.
Quite strange, that the setup behind NAT is not really well documented.
clamav EOL and debian volatile
Hi Christoph,
thanks for this great tut. you might want to add a step to include debian volatile to
sources.list since lenny's clamav version is EOL and will give errors.
I'm planning to use your tut as a good starting point to understand a mail server and then customize it.
postgresql instead of mysql (this should be easily done)
roundcube instead of squirrelmail (if it works with nginx, else no webmail)
mailscanner instead of amavisd (just to try)
no phpmyadmin or any of those risky tools. (why do you use them here?)
--
cga
To successfully install the system on ubuntu 10.10
Please let me thank you all who helping the world.
as you see in the supject i used ubuntu version 10.10 (not server edition) and you have to change the word
aptitude to apt-get insted. So the line style well be like this
$> apt-get install postfix-msql
You'll copy starting from install postfix-msql only and you well type by your hands the apt-get
If you are using your mouse to copy and paste you'll find the comman run automatic but if you are using the
Keyboard (qwerty) you have to press enter after every paste action.
Thank you
Mohammad
Not sure what you are talking
Not sure what you are talking about. There is no such package "postfix-msql" in Ubuntu. And apt-get and aptitude behave similar in this context.
Ubuntu 10.04 WARNING !!!!!
Adding this deb http://ftp.debian.org/debian/ lenny main non-free to sources then results in the following being flagged for upgrading;
ifupdown initramfs-tools libpci3 libxml-parser-perl pciutils tasksel
tasksel-data
Something in the then proceeds to break grub and its use of UUID=
Four testbed server rebuilds led me to this so install the attachment components for scanning then comment it out.
Ubuntu?
I like Ubuntu but If you are using it on a server in combination with this tutorial then you are completely on your own. Using debian.org repositories in combination with your Ubuntu repositories doesn't make sense.
unsupported dictionary type: mysql
Hi.
Great tutorial, but when I start postfix I get following message:
Apr 5 11:28:53 postfix/cleanup[21087]: fatal: unsupported dictionary type: mysql
All packages are installed.
Found no solution till now. My you help me someone ?
Dirk
Is postfix-mysql installed?
Is postfix-mysql installed?
Think I got it...
Yes is installed that's why i'm confused...
But I think there was a problem with the mysql-libs. Compiled postfix by hgand now with the same version and included the mysql-libs from the correct location. Now it's working and I can go on with the tutorial :)
FYI: Debian is installed by provider on a vserver... think there's the Knackpunkt *g*
Thx for pretty fast reply :)
wfinnish
By installing squirrelmail on squeeze my system wanted me to install wfinnish, a finnish dictionary.
If you want to install a german dictionary you need to install w(n|o)german for the new or old spelling. wgerman doesn't exist.