--- category: '' date: 2004/05/21 20:21 description: '' link: '' priority: '' slug: '28' tags: qmail title: Qmail Address Lister type: text updated: 2004/05/21 20:21 url_type: '' --- .. raw:: html
What does this proggie do? Well, it lists qmail's users, that's what!
Sometimes, for some reason, you will want a list of all valid addresses on a qmail system. This is not that. It stops too soon (see below), but it is close.
I wrote this to use with some squirrelmail plugin, so the output may not be what you expect, but it's easy to change.
It does, however, give you all first-level mail addresses (no sub-addresses like joe-spam@spamjoe.com), because there are potentially an infinite number of those. Also, it ignores aliases.
It tries to figure out if something is really wrong with your users, and warn you.
Assuming you are using a "classical" multi-user qmail system, every domain listed in /var/qmail/control/locals is valid for all users. So, I get the list of users and cross it with that list, to get a bunch of addresses.
For each domain in /var/qmail/control/virtualdomains, there is a prefix. Usually (I assume this), that prefix will match a user's name, and all sub-addresses of that user, as defined in his .qmail-* files, are valid addresses for this domain.
So, I fetch that. For each domain (say, virtualdomain) I get the prefix (say pref), I read all .qmail files in /home/pref (say .qmail-ext) and add an address of the form p-ext@virtualdomain .
Keep in mind that .qmail files feeding programs or whatever will confuse the bejeezus out of this script. However, the net effect should simply be some weird address in the output, nothing else.
It is not meant to be fast, or short, but it is meant to be written clearly!
The variable names are in spanish for reason of lazyness ;-)