skip navigation

www.Hilands.com


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
Configurations
We will be using postconf to edit the /etc/postfix/main.cf file
The myorigin and myhostname should already exist, however we'll show how to modify them anyway. # postconf -e "myorigin = mail.example.com"
# postconf -e "myhostname = mail.example.com" The relay domain will allow postfix to mail from the designated domain(s). # postconf -e "relay_domains = example.com"
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 example.com all localized mail on the system will send to example.com instead of the server mail.example.com. 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
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
220 postfix.example.com ESMTP Postfix (Debian/GNU)
mail from:<phil@hilands.com>
250 2.1.0 Ok
rcpt to:<phil@hilands.com>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
To: phil@hilands.com
From: phil@hilands.com
Subject: Test Email
This is a test email of the postfix configs

.

250 2.0.0 Ok: queued as 80B8325E2DA
quit
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
                                         root

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

D6E562481BE      489 Mon Feb 11 10:40:01  smmsp
                                         root

A331A2481BD      489 Mon Feb 11 10:20:01  smmsp
                                         root

40CE52482CC     2038 Thu Feb  7 19:17:03  saot-help@ucdavis.edu
               (connect to password.com[50.57.34.52]:25: Connection timed out)
                                         password@password.com

-- 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
Troubleshooting
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 root@example.com 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!
References