Installing iRedMail And Mailman On Debian Squeeze

Version: 1
Author: Jason Norwood-Young
Last edit: 22 December 2011

I'm a big fan of iRedMail, which is basically a packaged version of Postfix and the other bits that make Postfix cool, like Spamassassin, greylisting and an LDAP or MySql back-end. One thing I wanted with iRedMail is Mailman, my favourite mailing list server. Integrating the two can be a mission though, so here's some instruction to save you from quite a bit of pain.

The iRedMail guys offer a free admin console for managing user accounts. I subscribe to iRedMail's Pro version of its admin console, which is very useful for clients to self-manage. I don't have anything to do with iRedMail, apart from being a customer.

1. Setting up the server

I'm installing on a clean Debian Squeeze install. The first thing I always do on a new server is:

apt-get update
apt-get upgrade
dpkg-reconfigure tzdata

The last line allows you to set your timezone. It isn't strictly necessary for our purposes, but I consider it good practice to set this up.

Now we need to set up a fully-qualified domain name (FQDN). That means we need a domain like mailserver.example.com instead of just mailserver. To check what your hostname is, type:

hostname -f

NOTE: The domain name you choose should be different from the email domain you wish to use. If you want your email to come from joebob@example.com, do not make your server name example.com - give it a subdomain like obiwan or captainkirk or (if you're boring like me) mailserver.

If you already have a FQDN, you can move on to step 2.

The domain name is set in two places: /etc/hostname and /etc/hosts.

Edit your /etc/hostname to contain your FQDN (for the purposes of this tutorial I will use mailserver.example.com).

iRedMail will install everything you need. Accept all the defaults except for the backend - choose MySql instead of LDAP. When prompted for your first virtual mail domain, put in example.com, NOT mailserver.example.com. Answer Yes whenever prompted.

You now have a rocking mail server! That was easy, huh?

3. Installing Mailman

First we install Mailman:

apt-get install mailman

You'll note that Mailman doesn't get started yet. First we need to tell Postfix to send mail to Mailman when it receives mail from certain addresses.

4. Setting up Transport and Alias accounts

We're going to create a virtual domain called lists.example.com, which we're going to use for all our Mailman stuff. Whenever something gets sent to the domain lists.example.com, we're going to forward that on to the Mailman program instead of handling it like a normal mail.

Since we don't want our mailing list to be on the domain lists.example.com but rather just example.com, we'll also be setting up a bunch of aliases to accept the mails sent to Mailman addresses on example.com and instead route them to lists.example.com.

We're going to do all this through the MySql database. Point a browser at https://example.com/phpmyadmin. Notice that it is https and not just http. Also note that if you don't have a name server pointing at your IP address already, you might need to add example.com to your /etc/hosts file on your local computer.

Log in with user root and the password you chose during the iRedMail installation. If you can't remember any details, check out ~/iRedMail-0.7.3/iRedMail.tips - iRedMail conveniently saves the locations, usernames and passwords for all iRedMail services in there.

Click on the "vmail" database in the left panel, and then the "SQL" tab. Paste the following command into the tab (after changing the domain to your own of course) and hit Go:

5. Setting up Postfix

6. Turn off Greylisting

Now you will probably want to turn off Greylisting. Greylisting simply returns all mail it receives from a new sender. If the sender tries to send again in a while, it's probably not a spam bot. It's very effective at stopping spam, but it often means delays between someone sending you a mail and you receiving it. In the case of Mailman, if the message to Mailman is delayed for an hour, it makes the system feel unresponsive - especially for new subscribers. It also makes testing a hassle. You don't need to turn it off - the next bit is optional.

Edit /etc/postfix-policyd.conf:

[...]
GREYLISTING=0
[...]

Now restart the Postfix policy thingy:

/etc/init.d/postfix-policyd restart

7. Configuring Mailman

We're going to tell Mailman to send mail from @example.com instead of @lists.example.com. However, all links it sends need to come from the lists.example.com domain. This is because we're going to set up a virtual domain just for Mailman.

9. Creating your first list

Fill in your administrator's email address and password. It'll prompt you to hit Enter to notify the administrator. When you do this, you won't get an email immediately. We have one more step to do:

/etc/init.d/mailman start

Once we do that, the list administrator should get an email with a link to the admin interface of the new list.

If that works, you'll also want to test subscriptions (just send a blank mail to mailman-subscribe@example.com). If you get a subscription confirmation back and you are able to click on the link, then most likely everything is working 100%. If not, panic! I mean, have a look at /var/log/mail.log to get an idea of what's going wrong.

Hint: to keep an eye on the mail log, use:

tail -f /var/log/mail.log

If you need to try to recreate the Mailman list, first run:

rmlist mailman

10. Creating more lists

To create a list called "listname", first add the new list's aliases to the aliases table in the MySql vmail database: