Setup Postfix in Debian

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

Postfix is a widely used mail server, or more specifically, an MTA (Mail Transfer Agent). In this article, we describe how to install Postfix on Debian Lenny 5.0. In this example, we use a test server (lists.wefi.net). Replace this name with the name of your server.

Install package

The Postfix installation must be started on the command line as follows:

apt-get install postfix

Debian provides a note that Exim is removed and questions if you want to continue with the installation:

lists:~# apt-get install postfix
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin libsasl2-modules
  resolvconf postfix-cdb ufw
The following packages will be REMOVED:
  exim4 exim4-base exim4-config exim4-daemon-light
The following NEW packages will be installed:
  postfix
0 upgraded, 1 newly installed, 4 to remove and 0 not upgraded.
Need to get 1224kB of archives.
After this operation, 1008kB disk space will be freed.
Do you want to continue [Y/n]? y
Get:1 http://http.at.debian.org lenny/main postfix 2.5.5-1.1 [1224kB]
Fetched 1224kB in 0s (6060kB/s)
Preconfiguring packages ...

Package configuration

Postfix Configuration: General type of mail configuration

In the first configuration step, we select Internet Site in this example. Select the corresponding entry depending on your individual requirements.

Package configuration
         ┌───────────────────────────┤ Postfix Configuration ├───────────────────────────┐
         │ Please select the mail server configuration type that best meets your needs.  │ 
         │                                                                               │ 
         │  No configuration:                                                            │ 
         │   Should be chosen to leave the current configuration unchanged.              │ 
         │  Internet site:                                                               │ 
         │   Mail is sent and received directly using SMTP.                              │ 
         │  Internet with smarthost:                                                     │ 
         │   Mail is received directly using SMTP or by running a utility such           │ 
         │   as fetchmail. Outgoing mail is sent using a smarthost.                      │ 
         │  Satellite system:                                                            │ 
         │   All mail is sent to another machine, called a 'smarthost', for delivery.    │ 
         │  Local only:                                                                  │ 
         │   The only delivered mail is the mail for local users. There is no network.   │ 
         │                                                                               │ 
         │ General type of mail configuration:                                           │ 
         │                                                                               │ 
         │                            No configuration                                   │ 
         │                            Internet Site                                      │ 
         │                            Internet with smarthost                            │ 
         │                            Satellite system                                   │ 
         │                            Local only                                         │ 
         │                                                                               │ 
         │                                                                               │ 
         │                     <Ok>                         <Cancel>                     │ 
         │                                                                               │ 
         └───────────────────────────────────────────────────────────────────────────────┘ 
Postfix Configuration: System mail name

In the second step, we state the mail name of the server. Since the example involves a mailing list server, here lists.wefi.net (the mail address, for example, is then mailingliste@lists.wefi.net):

Package configuration

 ┌──────────────────────────────────┤ Postfix Configuration ├───────────────────────────────────┐
  │ The "mail name" is the domain name used to "qualify" _ALL_ mail addresses without a domain   │ 
  │ name. This includes mail to and from <root>: please do not make your machine send out mail   │ 
  │ from root@example.org unless root@example.org has told you to.                               │ 
  │                                                                                              │ 
  │ This name will also be used by other programs. It should be the single, fully qualified      │ 
  │ domain name (FQDN).                                                                          │ 
  │                                                                                              │ 
  │ Thus, if a mail address on the local host is foo@example.org, the correct value for this     │ 
  │ option would be example.org.                                                                 │ 
  │                                                                                              │ 
  │ System mail name:                                                                            │ 
  │                                                                                              │ 
  │ lists.wefi.net______________________________________________________________________________ │ 
  │                                                                                              │ 
  │                          <Ok>                              <Cancel>                          │ 
  │                                                                                              │ 
  └──────────────────────────────────────────────────────────────────────────────────────────────┘ 

Completion of installation

(Reading database ... 21540 files and directories currently installed.)
Removing exim4 ...
dpkg: exim4-config: dependency problems, but removing anyway as you request:
 exim4-base depends on exim4-config (>= 4.30) | exim4-config-2; however:
  Package exim4-config is to be removed.
  Package exim4-config-2 is not installed.
  Package exim4-config which provides exim4-config-2 is to be removed.
 exim4-base depends on exim4-config (>= 4.30) | exim4-config-2; however:
  Package exim4-config is to be removed.
  Package exim4-config-2 is not installed.
  Package exim4-config which provides exim4-config-2 is to be removed.
Removing exim4-config ...
dpkg: exim4-daemon-light: dependency problems, but removing anyway as you request:
 bsd-mailx depends on exim4 | mail-transport-agent; however:
  Package exim4 is not installed.
  Package mail-transport-agent is not installed.
  Package exim4-daemon-light which provides mail-transport-agent is to be removed.
Removing exim4-daemon-light ...
Stopping MTA: exim4_listener.
Removing exim4-base ...
Processing triggers for man-db ...
Selecting previously deselected package postfix.
(Reading database ... 21404 files and directories currently installed.)
Unpacking postfix (from .../postfix_2.5.5-1.1_i386.deb) ...
Processing triggers for man-db ...
Setting up postfix (2.5.5-1.1) ...
Adding group `postfix' (GID 108) ...
Done.
Adding system user `postfix' (UID 104) ...
Adding new user `postfix' (UID 104) with group `postfix' ...
Not creating home directory `/var/spool/postfix'.
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
Adding group `postdrop' (GID 109) ...
Done.
setting myhostname: lists.wefi.net
setting alias maps
setting alias database
changing /etc/mailname to lists.wefi.net
setting myorigin
setting destinations: lists.wefi.net, localhost.wefi.net, , localhost
setting relayhost: 
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all
WARNING: /etc/aliases exists, but does not have a root alias.

Postfix is now set up with a default configuration.  If you need to make 
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
Stopping Postfix Mail Transport Agent: postfix.
Starting Postfix Mail Transport Agent: postfix.
lists:~# 

Verification of mail delivery

You can verify with telnet (as described in Test TCP Port 25 (smtp) access with telnet) if the mail delivery functions:

ubuntu@ubuntu:~$ telnet lists.wefi.net 25
Trying 80.66.32.103...
Connected to lists.wefi.net.
Escape character is '^]'.
220 lists.wefi.net ESMTP Postfix (Debian/GNU)
EHLO test.example.com
250-lists.wefi.net
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: test@example.com
250 2.1.0 Ok
RCPT TO: postmaster@lists.wefi.net
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test message

This is a test.

.
250 2.0.0 Ok: queued as 87D2CDE40A2
QUIT
221 2.0.0 Bye
Connection closed by foreign host.
user@ubuntu:~$ 

This message has now been delivered to the server:

lists:~# mail
Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/root": 1 message 1 new
>N  1 test@example.com  Tue Jun  1 10:00   16/545   Testnachricht
& 1
Message 1:
From test@example.com  Tue Jun  1 10:00:49 2010
X-Original-To: postmaster@lists.wefi.net
Subject: Testnachricht
Date: Tue,  1 Jun 2010 10:00:08 +0200 (CEST)
From: test@example.com
To: undisclosed-recipients:;

This is a test. 


& q
Saved 1 message in /root/mbox
lists:~# 

More information


Author: Werner Fischer

Werner Fischer, working in the Knowledge Transfer team at Thomas-Krenn, completed his studies of Computer and Media Security at FH Hagenberg in Austria. He is a regular speaker at many conferences like LinuxTag, OSMC, OSDC, LinuxCon, and author for various IT magazines. In his spare time he enjoys playing the piano and training for a good result at the annual Linz marathon relay.


Translator: Alina Ranzinger

Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.


Related articles

Debian GNU/Linux
Hard Disk Formatting/Partitioning and Mounting in Debian Linux
Setting up password authentication with Active Directory on Debian