The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Things look quiet here. But I've been doing a lot of blogging at dan.langille.org because I prefer WordPress now. Not all my posts there are FreeBSD related. I am in the midst of migrating The FreeBSD Diary over to WordPress (and you can read about that here). Once the migration is completed, I'll move the FreeBSD posts into the new FreeBSD Diary website.

majordomo and virtual mailing lists 3 April 1999
Need more help on this topic? Click here
This article has no comments
Show me similar articles
One great strength of majordomo is the ability to run virtual mailing lists, like blacktop@theirdomain.org and potplants@yourdomain.org, from the same machine.

If you want to know more about virtual machines, see http://cybernut.com/guides/virtual.html

The resources
As with everything, I don't figure these things out on my own.  I use what someone else has already written.  In this case, I've used the majordomo FAQ which contains a section on virtual domains.   From there, it refers to Ernest Mueller's extremely useful article on Configuring Virtual Domains.
Assumption
I will assume you have already configured sendmail to handle virtual domains.   I used Jim Mock's article on sendmail Virtual Hosting.  I found it very easy, using that article, to add virtual sendmail domains to my machine.  I will also assume you have already installed majordomo.

For this example, you are creating the mailing list yourlist@yourdomain.org.

A new majordomo configuration file
I created a new config file for the virtual domain yourdomain.org (if you already have other virtual domains sitting around, you could use that majordomo configuration file as a starting point) :
# cd /usr/local/majordomo
# cp majordomo.cf majordomo.yourdomain.org.cf
# chown majordom:majordom majordomo.yourdomain.org.cf

Then I modified the new file to contain these values:

$whereami = "yourdomain.org";
$listdir = "$homedir/lists/$whereami";
$digest_work_dir = "$homedir/lists/$whereami/digests";
$log = "$homedir/lists/$whereami/Log";
New virtual users
These are the aliases you need to add to /etc/mail/virtusertable.   A template is available from samples/majordomo.virtusertable.txt.   Make the changes as shown in the comments at the top of the file.

Here is what you can find in the template.

#
# yourdomain.com
#
owner-majordomo@yourdomain.com       owner-majordomo-yourdomain-com
majordomo-owner@yourdomain.com       owner-majordomo-yourdomain-com
majordomo@yourdomain.com             majordomo-yourdomain-com

The following is needed for each list in a given virtual domain:

#
# yourlist mailing list
#
yourlist-owner@yourdomain.com        owner-yourlist-yourdomain-com
owner-yourlist@yourdomain.com        owner-yourlist-yourdomain-com
yourlist@yourdomain.com              yourlist-yourdomain-com
yourlist-request@yourdomain.com      yourlist-yourdomain-com-request
yourlist-approval@yourdomain.com     yourlist-yourdomain-com-approval

If you have a digest version of your list, you'll need one of the above sections for the list and another one for the digest.

After you add these entries, you need to build the virtual user database.  To do so, run the following command:

makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
A new majordomo alias file

We will now create an alias file which defines both mojordomo for this domain and the mailing list. This file defines aliases for a digest.  A template is example in a separate file because the lines are very long.  Use the template text available from sample/majordomo.alias.txt.

As you example that template, let's assume the following:

  • your list name is mountainbikes
  • your domain name is mountainbikes.com
  • the list owner is blarf@anotherdomain.com

If that is the case, then you need to make the following changes to the template data:

original text new text
yourlist mountainbikes
yourdomain.com mountainbike.com
yourdomain-com mountainbike-com
owner@ownerdomain.com blarf@anotherdomain.com

This file goes in /etc/mail. Name it aliases.majordomo.yourdomain.com.

You will also need to add this file to /etc/mail/sendmail.cf, or, if you are using it, your sendmail.m4 file (see following sections for details). Here's an example:

 location of alias file
O AliasFile=/etc/mail/aliases,/etc/mail/aliases.majordomo.yourdomain.com

After creating the file and updating sendmail.cf, remember to run newaliases. See the next sections for details.

Tell sendmail about the majordomo aliases
Now that we have created these majordomo aliases, we need to make sure that sendmail knows about them.  We do that by modifying the our .mc file.   Instructions for modifying your .mc file are included in the upgrading sendmail article.  In short, here's what you do:
# cd /usr/ports/mail/sendmail-8.9.3/cf/cf/

.mc files are normally of the form hostname.mc, where hostname is the name of your machine.  If you don't have a .mc file, you are welcome to use samples/hendrix.mc from my system.  You will need to edit this file and ensure the following appears in that file:

#
# The aliases after installing  majordomo
#
define(`ALIAS_FILE',`/etc/aliases,/etc/aliases.majordomo,\
                         /etc/aliases.majordomo.yourdomain.org')

WARNING: the above "define" example should be all on one line.  It appears as two lines above to keep the page narrow.

The key point here is that you add the alias file which you created in the previous step.

Now you need to generate your new sendmail.cf file:

# m4 ../m4/cf.m4 hostname.mc > sendmail.cf
# cp /etc/sendmail.cf /etc/sendmail.cf.bak
# cp sendmail.cf /etc
Create new aliases
After adding new aliases, you must recreate the alias database.  This is done simply by issuing the following command:
# newaliases

You should check for errors by doing the following:

# tail /var/log/messages

The following indicates a successful run:

sendmail[90764]: alias database /etc/aliases.majordomo rebuilt by peter
sendmail[90764]: /etc/aliases.majordomo: 31 aliases, longest 118 bytes,
                                                       1834 bytes total
If you created a digest for your list, you'll have to create and chown the respective directoires.  I originally did this in Creating a digest and archive for a majordomo mailing list but I've copied the relevent bits here.   Again, subsitute as appropriate for your situation.
# Let's assume the following:
#        your list name is mountainbikes
#        your domain name is mountainbikes.com
#
# Then you need to make the following changes:
#    original text             new text
#    yourlist                  mountainbikes
#    yourdomain.com            mountainbike.com

mkdir /usr/local/majordomo/lists/yourdomain.com/digests/
chown majordom /usr/local/majordomo/lists/yourdomain.com/digests
mkdir /usr/local/majordomo/lists/yourdomain.com/digests/yourlist-digest
chown majordom /usr/local/majordomo/lists/yourdomain.com/digests/yourlist-digest
chmod 750 /usr/local/majordomo/lists/yourdomain.com/digests/yourlist-digest
mkdir /usr/local/majordomo/lists/yourdomain.com/yourlist.archive
chown majordom /usr/local/majordomo/lists/yourdomain.com/yourlist.archive
chmod 750 /usr/local/majordomo/lists/yourdomain.com/yourlist.archive
Restart sendmail and check for errors
After all of this work, it's time to restart sendmail so it can take notice of the new aliases you have created.
# killall -HUP sendmail

Check for any errors by doing this:

# tail /var/log/maillog

If it looks something like this, then you're OK

ns sendmail[90896]: restarting /usr/sbin/sendmail on signal
ns sendmail[90901]: starting daemon (8.9.3): SMTP+queueing@00:15:00
Creating a new list

For this example, I'll be using my creation of the New Zealand FreeBSD User Group (nzfug) mailing list. The address we want to use for subscribing is majordomo@yourdomain.org. These steps will put all mailing lists relating to a given domain in the directory /usr/local/majordomo/lists/yourdomain.org. Remember this point when it comes time to configure majordomo in the following sections.

  1. cd /usr/local/majordomo/lists
  2. mkdir yourdomain.org
  3. chown majordom:majordom yourdomain.org
  4. cd yourdomain.org
  5. touch mountainbikes
  6. chown majordom:majordom mountainbikes
  7. chmod 640 mountainbikes
  8. echo 'config mountainbikes mountainbikes.admin' | mail majordomo@yourdomain.com

    If you are creating virtual domains or if you are not on the box on which majordomo resides, then you need to specify the domain in the mail message (i.e. majordomo@yourdomain.org).

  9. Modify newlist.config which the previous step created. Change passwords, add footers, etc. You may also wish to see my list of Commonly Changed Configuration Items.
  10. echo 'subscribe mountainbikes' | mail majordomo@yourdomain.com
  11. Respond to any email that majordomo sends back to you. This is normally confirmation that you have supplied a valid email address and that you are subscribing yourself and not somebody else.
  12. test the list by send a message to the list at mountainbikes@yourdomain.com
Finished
With all that work, you should now be able to use your virtual mailing lists.  Try subscribing.  See what happens.  Remember, when you subscribe, you need to send to majordomo@yourdomain.org.

I've just rewritten large portions of this article.  If you notice any omissions or errors, please add your comments.


Share
Need more help on this topic? Click here
This article has no comments
Show me similar articles