Adding DNSBL to Postfix can be a great advantage as these services will help you defend against email spam. What these services does, is to provide a realtime database over IP addresses that are sending spam. If Postfix gets a positive result looking at a certain IP address, it will reject that mail.


OS: Ubuntu/Debian

Installation is simple, you just need to edit the file of Postfix.

nano /etc/postfix/

Edit the line starting with

smtpd_recipient_restrictions = ...

In the end of that line before “permit” insert content like this

, reject_rbl_client, reject_rbl_client, reject_rbl_client

Reload Postfix to load the new rules

/etc/init.d/postfix reload

You can specify as many DNSBL servers you like.

Running a virtual host invironment might from time to time require different configurations for each host. Recently i was asked to disallow the POST method while whitelisting the method for a few IP numbers – someone must have abused some kind of formular on the homepage.

The limitation was achieved in the following way.

Inside the tags of:

<VirtualHost *:80>

You should place the following code.

RewriteEngine on
RewriteCond %{THE_REQUEST} ^(POST)\ /.*\ HTTP/\d\.\d$
RewriteCond %{REMOTE_ADDR} !(x.x.x.x|y.y.y.y)
RewriteRule .* - [F]

Then restart Apache and the configuration will be loaded.


  • Line 2: You can specify several methods inside the parentheses seperated by a pipe (|). For instance (POST|HEAD)
  • Line 3: Insert the desired IP adresses to be whitelisted, again seperated by a pipe (|).


You will have to have the Apache rewrite module installed and enabled.

Available methods can be found under Apache docs.

These steps can be used in order to migrate content of a Courier IMAP account into a Dovecot IMAP account. Have in mind if you are using these steps for POP3, that all emails from the server will be re-downloaded (in case you are leaving a copy on the server) causing a lot of duplicates in your email client.

Prerequisities: Obtain a copy of your courier content on the dovecot server preferably in /var/tmp/

Enter the Dovecot Maildir folder and empty it

cd /var/vmail/[]/[user]/Maildir/
rm -rf ./* ./.*

Copy your Courier mailbox content

cp -R /var/tmp/[user]/. .

Search and replace the content of courierimapsubscribed and rename/copy it

sed -i 's/\(INBOX.\|INBOX\)//g' courierimapsubscribed
sed -i '/^$/d' courierimapsubscribed
cp courierimapsubscribed subscriptions

Rename courierimapuiddb

mv courierimapuiddb dovecot-uidlist

Change ownership of the whole into vmail

chown -R vmail:vmail ./* ./.*

That’s it! Now go browse your content from webmail or your favorite email client.