Linux logo

How to deploy, configure and troubleshoot Postfix on Debian 7 (Wheezy)

Postfix is a free, open source mail transfer agent (MTA) that routes and delivers electronic mail.

I recently decided it might be a good idea to deploy the package in my own local network as it is a central point of configuration to an upstream SMTP server. This will come in handy later on should I decide to physically relocate my hardware and at the same time change my internet service provider.

Run commands without the “#” at the beginning.

Installing

  1. #su – root
  2. #apt-get update
  3. #apt-get upgrade
  4. #apt-get install postfixPostfix Installation 1Postfix Installation 2

Configuring SMTP Authentication to Smarthost

If your upstream SMTP host requires SMTP authentication, you will need to create a password file and add it to /etc/postfix/main.cf configuration file.
Ignore if not required

  1. #cd /etc/postfix
  2. #vi password

Add the following line
smtp.relay.com                                [email protected]:password

  • The first part needs to be the upstream SMTP server, this example is smtp.relay.com, separate by tab and type your username, add a “:” and type your password
  1. #chown root:root password
  2. #chmod 0600 password
  3. #postmap hash:password

Configuring

#vi /etc/postfix/main.cfmain.cf

Change:

  1. “relayhost” to your smart host upstream
  2. “inet_interfaces =” to all

Add:

  1. mynetworks = Add network address of internal network
  2. smtp_sasl_auth_enable = yes
  3. smtp_sasl_password_maps = hash:/etc/postfix/password
  4. smtp_sasl_security_options =
    :wq

Finishing Setup

#postfix check
#postfix reload
#netstat –tannetstat

Check to see Local Address of “0.0.0.0:25” is in a state of “LISTEN”

Troubleshooting

Check to see if postfix is running by executing the following command:

  1. #ps aux | grep postfix

Open a second terminal and monitor the mail.log file while in another session telnet to the Postfix server on port 25 and attempt to send a message manually

  1. #tail –f /etc/log/mail.log

This is an example of a successful sent email

mail

 Conclusion

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.