Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Not really familiar with sendmail as a full-on MTA, but I need to get a list of email addresses.

I've Googled around, and from that, I've checked /etc/mail/aliases (there's some in there, but this is mainly used for Blackberry forwarding as it seems incomplete) and virtusertable (empty) and from what I can tell, mail is delivered to local users. However, there's a lot of local UNIX users in there and by the date modified, I'm guessing a bunch are old.

Surely there must be another localpart (email address) to local user mapping somewhere or a better way to tell what email addresses are active (or at least, functioning; I can handle some inactive ones as missing some would be worse, obviously).

share|improve this question
up vote 2 down vote accepted

Depending on your software your logs are a good place to find the ids that are really being used. It also depends on how long you keep your mail logs. A little scripting magic and you should be able to get counts by email id.

Sendmail usually uses the standard mail.log file to log message deliveries. Once you have found the appropriate logs it shouldn't be too difficult to select and pars the delivery messages.

You will need to filter out messages sent to other systems (excluding you blackberry server).

Normally privileged accounts (UID < 500 or 1000) shouldn't be receiving email. Other than that any id acceptable to your authentication system should be valid. Try running getent passwd to get a list of users.

The various alias files are for redirecting delivery. Many aliases are for required ids like abuse and postmaster, or system ids like root to which many alias may point. You will want to filter out the system ids, and configure the required ids in your new server.

share|improve this answer
didn't think of logs; so simple. Was able to parse all the email addresses that have either sent or received mail in the last year. – gravyface Jul 22 '11 at 13:25

I assume you are using Linux or UNIX.

Sendmail will allow mail to all user accounts present in /etc/passwd (and depending on the authentication method you need to add NIS, and possibly AD users). Additionally, those users present in the alias file can be valid email addresses. BTW, to get a list of aliases, I use praliases (available on RH systems).

BTW, I have noticed password disabled users in the /etc/passwd and NIS accounts can still get email, I do not know personally about AD users.

There is another complication, all those "users" can receive locally to all domain names listed in /etc/mail/local-host-names.

Having said that, I'm a little confused as to what you might be wanting.

The information you seek is surely there but not in one file, nor one command.

share|improve this answer
I'm transitioning to a different mail server (Exchange, on SBS Server), so I'd like a list of all email addresses in use. – gravyface Jul 22 '11 at 0:42

i've seen instances in *nix distribs where there exist both /etc/aliases and /etc/mail/aliases - and the latter is not actually used (nor a link to /etc/aliases). can't hurt to see if /etc/aliases exists and may have more info in it...

share|improve this answer
Different distros put things in different places, absolutely right! – mdpc Jul 22 '11 at 0:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.