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 [email protected], 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).

For your /etc/hosts file, your first line should look like this:

127.0.0.1     mailserver.example.com mailserver localhost localhost.localdomain

Now we just need to tell the system to register the change:

/etc/init.d/hostname.sh 
hostname -f

You should now see a FQDN. If you don't get one, panic! Er, I mean reboot and check again.

 

2. Installing iRedMail

At time of writing, the iRedMail version is 0.7.3. Check on www.iredmail.org for the latest version and adjust accordingly.

cd ~ 
wget http://iredmail.googlecode.com/files/iRedMail-0.7.3.tar.bz2
apt-get install bzip2
tar xjf iRedMail-0.7.3.tar.bz2
cd iRedMail-0.7.3
bash iRedMail.sh

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:

INSERT INTO `vmail`.`domain` (`domain`, `description`, `disclaimer`, `aliases`, `mailboxes`, `maxquota`, `quota`, `transport`, `backupmx`, `defaultuserquota`, `defaultuseraliases`, `defaultpasswordscheme`, `minpasswordlength`, `maxpasswordlength`, `created`, `modified`, `expired`, `active`) VALUES ('lists.example.com', '', '', '0', '0', '0', '0', 'mailman:', '0', '1024', '', '', '0', '0', NOW(), '0000-00-00 00:00:00', '9999-12-31 00:00:00', '1');

That set up our Transport to get everything from lists.example.com to the Mailman app.

Now we need to add the Mailman aliases. You'll need to do this every time you add a new list to Mailman, just search-and-replace "mailman" with your new list name and run the SQL again.

INSERT INTO `alias` (`address`, `goto`, `name`, `moderators`, `accesspolicy`, `domain`, `created`, `modified`, `expired`, `active`) VALUES
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1);

 

5. Setting up Postfix

Back to the command line. We need to run:

postconf -e 'relay_domains = lists.example.com' 
postconf -e 'mailman_destination_recipient_limit = 1'
/etc/init.d/postfix reload

 

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.

pico /etc/mailman/mm_cfg.py
[...]
DEFAULT_URL_PATTERN = 'http://%s/'
[...]
DEFAULT_EMAIL_HOST = 'example.com'
[...]
DEFAULT_URL_HOST = 'lists.example.com'

 

8. Configuring Apache

We're almost done. We just need to configure the Apache server to serve the Mailman website whenever we go to lists.example.com. Don't forget to set up this domain in /etc/hosts or your nameserver.

pico /etc/apache2/sites-available/mailman
ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/
Alias /pipermail/ /var/lib/mailman/archives/public/
Alias /images/mailman/ /usr/share/images/mailman/
<Directory /usr/lib/cgi-bin/mailman/>
    AllowOverride None
    Options ExecCGI
    AddHandler cgi-script .cgi
    Order allow,deny
    Allow from all
    Satisfy Any
</Directory>
<Directory /var/lib/mailman/archives/public/>
    Options FollowSymlinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<Directory /usr/share/images/mailman/>
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<VirtualHost *:80>
    ServerName lists.example.com
    DocumentRoot /var/www/lists
    ErrorLog /var/log/apache2/lists-error.log
    CustomLog /var/log/apache2/lists-access.log combined
    <Directory /var/lib/mailman/archives/>
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    Alias /pipermail/ /var/lib/mailman/archives/public/
    Alias /images/mailman/ /usr/share/images/mailman/
    ScriptAlias /admin /usr/lib/cgi-bin/mailman/admin
    ScriptAlias /admindb /usr/lib/cgi-bin/mailman/admindb
    ScriptAlias /confirm /usr/lib/cgi-bin/mailman/confirm
    ScriptAlias /create /usr/lib/cgi-bin/mailman/create
    ScriptAlias /edithtml /usr/lib/cgi-bin/mailman/edithtml
    ScriptAlias /listinfo /usr/lib/cgi-bin/mailman/listinfo
    ScriptAlias /options /usr/lib/cgi-bin/mailman/options
    ScriptAlias /private /usr/lib/cgi-bin/mailman/private
    ScriptAlias /rmlist /usr/lib/cgi-bin/mailman/rmlist
    ScriptAlias /roster /usr/lib/cgi-bin/mailman/roster
    ScriptAlias /subscribe /usr/lib/cgi-bin/mailman/subscribe
    ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/
    ScriptAlias / /usr/lib/cgi-bin/mailman/listinfo
</VirtualHost>

Now we just need to enable this virtual host.

a2ensite mailman 
mkdir /var/www/lists
apache2ctl restart

 

9. Creating your first list

The first Mailman list is always "mailman". To create this list, run:

newlist mailman

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 [email protected]). 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:

INSERT INTO `alias` (`address`, `goto`, `name`, `moderators`, `accesspolicy`, `domain`, `created`, `modified`, `expired`, `active`) VALUES
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1),
('[email protected]', '[email protected]', '', '', 'public', 'example.com', NOW(), NOW(), '9999-12-31 00:00:00', 1);

Once that's done, run this command to create a new list:

newlist listname

Have fun with your new Mailman server! I hope you create some great email communities.

Share this page:

8 Comment(s)