skip navigation

Content:: Installing Postfix

Setup and Configure Postfix
Last Modified: 2014-02-06
Postfix is a mail server that is a great alternative to Sendmail. The following setup was done on Debian Squeeze netinst.

Table of Contents
Core installation
# apt-get update
# apt-get upgrade
Using apt-get to install postfix you will be prompted to select the type of configuration. Choose Internet site from the options. # apt-get install postfix
Postfix Configuration, Internet Site

After installing you will see the post fix daemon started in the mail.log file. # cat /var/log/mail.log
Apr  2 15:00:56 mail postfix/master[3890]: daemon started -- version 2.7.1, configuration /etc/postfix
We will be using postconf to edit the /etc/postfix/ file
The myorigin and myhostname should already exist, however we'll show how to modify them anyway. # postconf -e "myorigin ="
# postconf -e "myhostname =" The relay domain will allow postfix to mail from the designated domain(s). # postconf -e "relay_domains ="
Allow postfix to read the /etc/aliases file # postconf -e "alias_maps = hash:/etc/aliases"
Reload the Postfix Service # postfix reload * Note, if you set up myorigin to all localized mail on the system will send to instead of the server Use the proper DNS name of your server for myorigin
Testing the connection via telnet
Set up a terminal to watch the mail log # tail -f mail.log While this is running open another terminal and send an email via telnet. When the email is sent you should see the log file displayed on the screen.
# telnet localhost 25
Connected to localhost (
Escape character is '^]'.
220 ESMTP Postfix (Debian/GNU)
mail from:<>
250 2.1.0 Ok
rcpt to:<>
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
Subject: Test Email
This is a test email of the postfix configs


250 2.0.0 Ok: queued as 80B8325E2DA
221 2.0.0 Bye
Postfix Mail Queue
We can use the "mailq" and "postsuper" commands to manipulate the mail queue.

First to view the mail queue we can use mailq. # mailq
postqueue: warning: Mail system is down -- accessing queue directly
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
3E6EF2481B6      489 Mon Feb 11 09:40:01  smmsp

76A162481B7      489 Mon Feb 11 10:00:01  smmsp

D6E562481BE      489 Mon Feb 11 10:40:01  smmsp

A331A2481BD      489 Mon Feb 11 10:20:01  smmsp

40CE52482CC     2038 Thu Feb  7 19:17:03
               (connect to[]:25: Connection timed out)

-- 4 Kbytes in 5 Requests.
If the mail queue is empty you should see this response
postqueue: warning: Mail system is down -- accessing queue directly
Mail queue is empty

To delete the mail queue we can use postsuper with the -d option. # postsuper -d ALL
postsuper: Deleted: 5 messages
Removing sendmail Binary
If you installed sendmail via apt, you may need to remove it.
apt-get --purge remove sendmail-base sendmail-cf
You may get a bounce message stating that the sender address does not exist in the reply from MAIL FROM command.
Domain of sender address root@ does not exist (in reply from MAIL FROM command)
Domain of sender address does not exist (in reply from MAIL FROM command)
You may not have a hostname set, however this is very doubtful # hostname <newname>
You can view your host name by checking the hostname file in etc. # nano /etc/hostname
The most probably cause is not having an a record for your mail server!