Binding Postfix to an IP

By default, Postfix will listen on all IPs on a server. In the case of multi-homed servers, you may want to force Postfix to use a particular IP because of reverse dns, whitelisting, etc.

To do this, add the following to main.cf:
smtp_bind_address = x.x.x.x

You can the full details at http://www.postfix.org/postconf.5.html#smtp_bind_address.

How to delete messages from the Postfix queue

In this example, I wanted to delete all the messages that showed up as delivery temporarily suspended from the mail queue.

mailq | tail +2 | awk 'BEGIN {RS=""} /delivery temporarily suspended/ {print $1}' | tr -d '*!' | postsuper -d -

Note: This command should be entered all on one line.

Setting up pflogsumm on CentOS to run nightly

Here is a small post on how to setup pflogsumm on your CentOS mail server running Postfix.  It takes advantage of logrorate being called nightly by cron.

1. Install pflogsumm

# yum install postfix-pflogsumm

2. Run a test

# /usr/sbin/pflogsumm /var/log/maillog

3. Update /etc/logrotate.d/syslog.  Add the following:

 prerotate
    /usr/sbin/pflogsumm /var/log/maillog | mail -s "Postfix Logs Summary `date`" your-email-address
 endscript

Switching from Sendmail to Postfix on CentOS

Switching from sendmail to postfix on CentOS is pretty simple. You just need to remember a couple of simple steps.

1. Install the applications you’ll need
# yum install postfix
# yum install system-switch-mail

2. Configure postfix
3. Tell the system to switch from sendmail to postfix
# system-switch-mail

Removing sendmail will also tell the system to switch to postfix, but I recommend using system-switch-mail command. That way if you run into problems, you can switch back to sendmail without much trouble.