Manage Email Lists with GNU Mailman on Debian 6
- Deprecated guides:
- Ubuntu 9.10
- Ubuntu 12.04
- Ubuntu 10.10
- Ubuntu 10.04
- Debian 5
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
DeprecatedThis guide has been deprecated and is no longer being maintained.
GNU Mailman is a commonly used Listserv Management application that allows users to create and manage discussion and announcement email lists. Mailman includes support for numerous features including a web-based administrative interface, multiple domains, lists, and complex moderation and access control tools. The Mailman software is primarily written in the Python programing language and has been a popular choice for managing email lists for more than a decade.
Be sure to review this guide in its entirety before beginning the procedure outlined below. If you have an existing mail system configured before you begin this, take special care to ensure that installing Mailman will not conflict with delivery of existing mail.
Set the Hostname
Before you begin installing and configuring the components described in this guide, please make sure you’ve followed our instructions for setting your hostname. Issue the following commands to make sure it is set properly:
hostname
hostname -f
Installing Mailman
Before proceeding with the installation of Mailman, make sure your package repositories and installed programs are up to date by issuing the following commands:
apt-get update
apt-get upgrade --show-upgraded
Mailman can be configured to use a number of different mail transfer agents. We recommend using the postfix MTA, though mailman will work with whatever MTA you have installed. If you do not have any MTA installed, issue the following command to install postfix:
apt-get install postfix
During the postfix installation, you will want to select “Internet Site” as the “General type of mail configuration.” You will also want to set the host or domain name for your server as the system name, (e.g. example.com
or similar.) Now install Mailman with the following command:
apt-get install mailman
During the Mailman installation, you will be required to specify the languages that you wish your Mailman instance support. Select all required languages before continuing. The installation process will also provide a note regarding the next step of the installation process, which you can accept and allow the installation process to continue.
Configure Mailman
Consider the “ Configure Virtual Hosting” section before preceding. In most cases where you will be hosting you will want to skip this section and continue with that procedure. Mailman requires a “base” list, from which it can send email to welcome new members to lists and send password reminders when needed. Create this list by issuing the following command:
newlist mailman
During the list creation process, Mailman will prompt you for the administrators email address and an initial mailman password. Mailman will then produce the following output that you will want to include in your /etc/aliases
file.
- File: /etc/aliases
1
\#\# mailman mailing list mailman: "|/var/lib/mailman/mail/mailman post mailman" mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman" mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman" mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman" mailman-join: "|/var/lib/mailman/mail/mailman join mailman" mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman" mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman" mailman-request: "|/var/lib/mailman/mail/mailman request mailman" mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"
Replace example.com
and lists.example.com
with the relevant domains for your instance. Ensure that you have configured the
MX Records for both domains that you want to receive email with. Additionally, add the following lines to your /etc/postfix/master.cf
file:
- File: /etc/postfix/master.cf
1 2 3
mailman unix - n n - - pipe flags=FR user=list argv=/var/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${mailbox}
These lines enable postfix to hand off email to Mailman for processing directly. Add the following line to the /etc/postfix/transport
file, modifying lists.example.com
as needed.
- File: /etc/postfix/transport
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
lists.example.com mailman: # Configure Virtual Hosting Finally, modify the `/etc/mailman/mm_cfg.py` file to set the following values. After you've edited the `/etc/postfix/transport` file, and after every successive edit of this file, issue the following command to rebuild postfix's transport database: <dl class="relative file font-mono text-xs pull-out" x-data> <div class="absolute right-0 top-0 pt-3 pr-2" @click="$copy($refs.code)"> <button type="button" aria-label="copy" class="btn-icon"><svg class="fill-current text-brand mr-3" style="width: 0.875rem; height: 1rem;"><use href="#icon--copy"></use></svg></button> </div> <dt class="px-8 py-3 bg-titlecolor sm:rounded-t-md text-white"> File: /etc/aliases </dt> <dd class="overflow-x-auto" :class="{ 'is-scroll-x' : $isScrollX($refs.container) }" x-ref="container"> <div x-ref="code"><div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code><span class="lnt">1 </span><span class="lnt">2 </span><span class="lnt">3 </span><span class="lnt">4 </span></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">relay_domains</span> <span class="o">=</span> <span class="nv">$mydestination</span>, lists.example.com </span></span><span class="line"><span class="cl"><span class="nv">relay_recipient_maps</span> <span class="o">=</span> hash:/var/lib/mailman/data/virtual-mailman </span></span><span class="line"><span class="cl"><span class="nv">transport_maps</span> <span class="o">=</span> hash:/etc/postfix/transport </span></span><span class="line"><span class="cl"><span class="nv">mailman_destination_recipient_limit</span> <span class="o">=</span> <span class="m">1</span></span></span></code></pre></td></tr></table> </div> </div></div> </dd> </dl> This controls how Mailman processes the mail that it receives from postfix. Continue configuring Mailman by editing following file to update Mailman to interact properly with postfix: <dl class="relative file font-mono text-xs pull-out" x-data> <div class="absolute right-0 top-0 pt-3 pr-2" @click="$copy($refs.code)"> <button type="button" aria-label="copy" class="btn-icon"><svg class="fill-current text-brand mr-3" style="width: 0.875rem; height: 1rem;"><use href="#icon--copy"></use></svg></button> </div> <dt class="px-8 py-3 bg-titlecolor sm:rounded-t-md text-white"> File: /etc/postfix/master.cf </dt> <dd class="overflow-x-auto" :class="{ 'is-scroll-x' : $isScrollX($refs.container) }" x-ref="container"> <div x-ref="code"><div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code><span class="lnt">1 </span><span class="lnt">2 </span><span class="lnt">3 </span></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">mailman unix - n n - - pipe </span></span><span class="line"><span class="cl"> <span class="nv">flags</span><span class="o">=</span>FR <span class="nv">user</span><span class="o">=</span>list </span></span><span class="line"><span class="cl"> <span class="nv">argv</span><span class="o">=</span>/var/lib/mailman/bin/postfix-to-mailman.py <span class="si">${</span><span class="nv">nexthop</span><span class="si">}</span> <span class="si">${</span><span class="nv">mailbox</span><span class="si">}</span></span></span></code></pre></td></tr></table> </div> </div></div> </dd> </dl>
- File: /etc/postfix/transport
1
lists.example.com mailman:
Ensure that the fields DEFAULT_EMAIL_HOST
and DEFAULT_URL_HOST
match the sub-domain you are using for lists (e.g. lists.example.com
,) as follows:
- File: /etc/mailman/mm\\_cfg.py
1 2 3 4 5 6 7 8 9
#------------------------------------------------------------- # Default domain for email addresses of newly created MLs DEFAULT_EMAIL_HOST = 'lists.example.com' #------------------------------------------------------------- # Default host for web interface of newly created MLs DEFAULT_URL_HOST = 'lists.example.com' #------------------------------------------------------------- # Required when setting any of its arguments. add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
- File: /etc/mailman/mm\\_cfg.py
1 2 3 4
MTA = 'Postfix' POSTFIX_STYLE_VIRTUAL_DOMAINS = ['lists.example.com'] # alias for postmaster, abuse and mailer-daemon DEB_LISTMASTER = 'postmaster@example.com'
If you need to configure additional domains for use, ensure that you’ve made the proper additions to the relay_domains
field in the main.cf
file and /etc/postfix/transport
file. Append an item to the POSTFIX_STYLE_VIRTUAL_DOMAINS
line and create additional add_virtualhost
calls in the following form for every new domain:
- File: /etc/mailman/mm\\_cfg.py
1 2 3 4 5 6 7 8 9
#------------------------------------------------------------- # Default domain for email addresses of newly created MLs DEFAULT_EMAIL_HOST = 'lists.example.com' #------------------------------------------------------------- # Default host for web interface of newly created MLs DEFAULT_URL_HOST = 'lists.example.com' #------------------------------------------------------------- # Required when setting any of its arguments. add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
Modify the following line, if it exists
POSTFIX_STYLE_VIRTUAL_DOMAINS = [’lists.example.com’, ’lists.example.org']
- File: /etc/mailman/mm\\_cfg.py
1 2 3 4
add_virtualhost('lists.example.org', 'lists.example.org') # Modify the following line, if it exists POSTFIX_STYLE_VIRTUAL_DOMAINS = ['lists.example.com', 'lists.example.org']
Ensure that your domains have valid MX and A Records that point to your Linode. When you’ve finished configuring Mailman, issue the following commands to create the default list (which will prompt you to enter an address for the list administrator and a password), restart postfix, and start Mailman for the first time:
newlist mailman
/etc/init.d/postfix restart
/etc/init.d/mailman start
If you created lists using the /etc/aliases
method, you will have to recreate those lists by issuing the following commands.:
/var/lib/mailman/bin/genaliases
postmap /var/lib/mailman/data/virtual-mailman
From this point forward, you can create new lists by issuing newlist
commands as root. Additionally, all administration and functions of the Mailman lists can be accomplished by way of the web based interface.
Configuring Mailman with Alternate Mail Configurations
If you wish to deploy Mailman on a system that has an existing mail set up, such as the Postfix with Dovecot and MySQL or the Postfix with Dovecot and System Users configurations described in other documents, consider the following recommendations:
Complete your basic mail configuration according to the appropriate guide before beginning to install and configure Mailman.
It is absolutely crucial that the DEFAULT_EMAIL_HOST
and DEFAULT_URL_HOST
are not served by your previously configured email system. Any additional domains served by mailman by way of the add_virtualhost
function must also not overlap any domains served by another domain on this host. If these domains overlap there will be collisions, and neither system will function as expected.
In all other respects, as long as you deploy Mailman with virtual hosting on its own domain using Mailman with an existing email solution poses no complications. Congratulations, you now have a fully functional email list management solution!
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on