ALINK="#FF0000">
LINUX GAZETTE
[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]

"Linux Gazette...making Linux just a little more fun!"


A Quick and Easy Way to Set Up a Mailing List

By Lawrence Teo


1. Why do you need a mailing list?

Picture this:

You've just started working with your colleagues on a new project. After the first meeting, everyone agrees that sending e-mails about each other's progress to all the members in the group periodically is the way to go. Everybody leaves the table, and you send out your first message to your colleagues' e-mail addresses. Everything goes well for awhile... until somebody new joins the group. Now everybody has to update their long list of addresses in the "To:" field, some people forget, and the new person didn't receive all the e-mails and starts complaining. Gradually, things start turning into a mess.

As things become more haphazard, you say to yourself, "Now, if only I can send all my e-mails to a single address, and that e-mail will propagate out to everybody else." Well, that is possible. What you need is a mailing list.

Most of us aren't strangers to mailing lists, especially if you're an active or long-time participant in the Linux community. But trust me, there are people out there who aren't familiar with mailing lists and how convenient they can be.

Now, let's say you agree that you need a mailing list. But you don't have time to set up one. If you have been a participant in a public and busy mailing list such as Bugtraq, you'll notice that they run a mailing list management program such as Majordomo or ezmlm. If you want a simple mailing list, and you need it quick, you don't need to play around with those. Plus, you don't really need the more complex features they offer. A standard Linux system is sufficient for setting up a simple mailing list for a workgroup.

In this article, I'll discuss how to set up such a simple mailing list using the standard Mail Transfer Agents (MTAs) that come with a standard Linux distribution, such as sendmail, Postfix or exim. Remember, though, the keyword is simple. That means that our mailing list will not have the fancy features offered by the heavy duty mailing list management programs.

As an added bonus, I've written another article in this same Linux Gazette issue that discusses how to set up a simple web-based archive of this mailing list (it's entitled "Setting Up a Web-based Archive for a Mailing List"). But if a mailing list is all you need, and/or you don't have time, this article is all you need to read.

2. Setting up the mailing list

Setting up the mailing list is pretty straightforward. I'll first talk about what you need, and then proceed to the actual instructions on setting it up.

2.1 What you need

First, here's what you need to set up the mailing list:

Once you've got all the requirements, the very first thing you need to do is to check that your MTA is actually running. I usually check this by running netstat as follows:

lteo@mybox:~$ netstat -a | grep smtp
tcp        0      0 *:smtp                  *:*                     LISTEN

If the system responds with that line, it usually means that your MTA is up and running. If it is not running, you need to activate it. The actual way to do that depends on the system. For example, on Debian run "/etc/init.d/sendmail start". On Red Hat, run "/etc/rc.d/init.d/sendmail start". (Your system may have the script in a different location.) To make it permanent, do a "chmod +x /etc/init.d/sendmail" (or wherever). On Slackware, you'll have to uncomment the lines that activate sendmail in /etc/rc.d/rc.M, and either restart the system, or run it manually for now using the command in that file.

2.2 Let's set it up!

The first thing you need to do is to think of a name for your mailing list. For example, if the Linux box you're using is called mybox.example.com, you can call your mailing list address "theproject@mybox.example.com". Any e-mails sent to theproject@mybox.example.com will then be propagated to all e-mail addresses registered to it. For the purpose of this article, let's say we want the mails that reach that address to go out to linus@mybox.example.com, alan@example.net, and esr@example.org.

The next thing you need to do is to set up the MTA's aliases file. The aliases file is usually stored as /etc/aliases or /etc/mail/aliases depending on your Linux distribution. Once you locate it, fire up your favorite text editor and edit it. You may see some default lines in that file, such as "webmaster: root", "postmaster:root", and so on. Just ignore those lines and scroll to the end of the file. Now add the following lines:

# The Project mailing list
theproject:
  linus,
  alan@example.net,
  esr@example.org

You can now save and exit from your editor.

As you can see, we can just use the string "linus" for "linus@mybox.example.com" since our machine is mybox.example.com and linus is a user on the machine. You can write comments by placing them after the # symbol. The # symbol must be the first character in the line.

Important! Now here comes the extremely important step! Depending on which MTA you are using, you may need to run a command for your changes to the aliases file for it to take effect. If you don't, the mailing list will not work! The following table shows what command you need to run after editing the aliases file.

MTACommand
sendmailnewaliases
Postfixpostaliases /etc/aliases
exim[No command needed.]

Congratulations! You should now have a working mailing list. To test it, just send an e-mail to theproject@mybox.example.com, and see if linus@mybox.example.com, alan@example.net, and esr@example.org get it. Personally, I test my mailing lists using free webmail accounts just to see if it really works.

[Note: example.com, example.net and example.org are domain names reserved for testing per RFC 2606, and will never be assigned to real sites. So watch the spambots harvest the addresses above and send spam to nonexistent sites. Whee!   -Iron]

Adding and removing e-mail addresses is straightforward. Just use your text editor and add or remove those e-mail addresses from the aliases file. Again, remember to run that all-important command after editing the aliases file to inform the MTA that you've made changes.

There is one thing you need to know about this mailing list, though. Unlike the full-blown mailing lists run by majordomo or ezmlm, a third party can send e-mails to our mailing list address and it'll still be sent to our registered recipients' e-mail addresses. Therefore, there may be a security issue here. That's why I stressed so much that this mailing list is meant to be simple. But if you're using it within a small trusted workgroup, it should be fine. Also, you may want to avoid revealing your mailing list address to the public, both for security and privacy reasons, and also to avoid getting spammed.

2.3 Summary

That's about it regarding setting up the mailing list. Simple, isn't it? Just to make sure you don't miss out anything, here's a short summary of our previous discussion on setting up a mailing list:

  1. Make sure that your MTA is up and running. You can use the command "netstat -a | grep smtp" to check this.
  2. Choose a name for your mailing list, e.g. theproject@mybox.example.com.
  3. Add the mailing list addresses and register the e-mail addresses in the aliases file (either /etc/mail/aliases or /etc/aliases depending on your distribution).
  4. If you're using sendmail or postfix, run "newaliases" or "postaliases /etc/aliases" respectively. If you're using exim, you don't need to run anything.
  5. Test your mailing list by sending a test mail to theproject@mybox.example.com.

3. Parting notes

That's it! I hope you find your brand new mailing list useful. I've used this method of setting up mailing lists many times for my workgroups, friends, and whenever there's a need for a simple mailing list. Of course, this is just one way of setting up such a mailing list. If you've found this method useful, or if you have any comments or suggestions, please feel free to write to me about them. I would really like to hear from you.

Remember, if you want to know how to set up a web-based archive of this list, you can read "Setting Up a Web-based Archive for a Mailing List", also in this issue of Linux Gazette.

Till then, have fun!

Lawrence Teo

Lawrence Teo is a Ph.D. student at the University of North Carolina at Charlotte. He researches on intrusion detection and critical infrastructure protection technologies with his research unit, the Laboratory of Information Integration, Security, and Privacy (LIISP). Lawrence has previously worked as a contract software engineer at Lycos, Singapore and as a research assistant at DSTC in Melbourne, Australia. He holds an Honors Degree in Bachelor of Computing from Monash University in Melbourne, Australia. You can send him e-mail at lawrenceteo<SPAM>@lycos.com.


Copyright © 2001, Lawrence Teo.
Copying license http://www.linuxgazette.net/copying.html
Published in Issue 72 of Linux Gazette, November 2001

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]