majordomo and virtual mailing listsOne great strength of majordomo is the ability to run virtual mailing lists, like firstname.lastname@example.org and email@example.com, from the same machine.
If you want to know more about virtual machines, see http://cybernut.com/guides/virtual.html
The resourcesAs 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.
AssumptionI 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 firstname.lastname@example.org.
A new majordomo configuration fileI 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 usersThese 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 # email@example.com owner-majordomo-yourdomain-com firstname.lastname@example.org owner-majordomo-yourdomain-com email@example.com majordomo-yourdomain-com
The following is needed for each list in a given virtual domain:
# # yourlist mailing list # firstname.lastname@example.org owner-yourlist-yourdomain-com email@example.com owner-yourlist-yourdomain-com firstname.lastname@example.org yourlist-yourdomain-com email@example.com yourlist-yourdomain-com-request firstname.lastname@example.org 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 email@example.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 firstname.lastname@example.org email@example.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 aliasesNow 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 aliasesAfter adding new aliases, you must recreate the alias database. This is done simply by issuing the following command:
You should check for errors by doing the following:
# tail /var/log/messages
The following indicates a successful run:
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.sendmail: alias database /etc/aliases.majordomo rebuilt by peter sendmail: /etc/aliases.majordomo: 31 aliases, longest 118 bytes, 1834 bytes total
# 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 errorsAfter 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: restarting /usr/sbin/sendmail on signal ns sendmail: 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 firstname.lastname@example.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.
- cd /usr/local/majordomo/lists
- mkdir yourdomain.org
- chown majordom:majordom yourdomain.org
- cd yourdomain.org
- touch mountainbikes
- chown majordom:majordom mountainbikes
- chmod 640 mountainbikes
- echo 'config mountainbikes mountainbikes.admin' | mail email@example.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. firstname.lastname@example.org).
- 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.
- echo 'subscribe mountainbikes' | mail email@example.com
- 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.
- test the list by send a message to the list at firstname.lastname@example.org
FinishedWith 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 email@example.com.
I’ve just rewritten large portions of this article. If you notice any omissions or errors, please add your comments.