Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   List of all email users (http://www.linux-archive.org/centos/184928-list-all-email-users.html)

John R Pierce 10-30-2008 02:39 PM

List of all email users
 
Jussi Hirvi wrote:

For real-world use, I guess the source files (in my case aliases,
virtusertable) should be prepared first - the list will include unwanted
users like "bin" or "mysql", mailing list name defined in virtusertable, and
possibly other strange things too.




and what about the user accounts in /etc/passwd ?


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Ralph Angenendt 10-30-2008 03:26 PM

List of all email users
 
Jussi Hirvi wrote:
> Ralph Angenendt (ra+centos@br-online.de) kirjoitteli (30.10.2008 17:12):
>> for i in /etc/aliases /etc/postfix/virtual; do
>> cat $i | grep -Ev "(^#|^s+$|^$)" | sed -e "s/://" | awk '{print $1}' |
>> sort -u | tr
,
>> done
>
> Thanks, that looks neat, and works.
>
> For real-world use, I guess the source files (in my case aliases,
> virtusertable) should be prepared first - the list will include unwanted
> users like "bin" or "mysql", mailing list name defined in virtusertable, and
> possibly other strange things too.

And (I forgot to say that) - it weeds out users with a ":" in their mail
address, which is completely valid. So you should check that also.

Cheers,

Ralph
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Jussi Hirvi 10-31-2008 10:11 AM

List of all email users
 
John R Pierce (pierce@hogranch.com) kirjoitteli (30.10.2008 17:39):
> and what about the user accounts in /etc/passwd ?

Hm, yes, never thought of that! That would be a very good (certainly easy)
approach, though with its own limitations (it misses those users whose mail
is forwarded in /etc/aliases to external addresses like gmail.com etc.).

- Jussi

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. & fax +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
jussi.hirvi@greenspot.fi * http://www.greenspot.fi

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Bill Campbell 10-31-2008 06:49 PM

List of all email users
 
On Fri, Oct 31, 2008, Jussi Hirvi wrote:
>John R Pierce (pierce@hogranch.com) kirjoitteli (30.10.2008 17:39):
>> and what about the user accounts in /etc/passwd ?
>
>Hm, yes, never thought of that! That would be a very good (certainly easy)
>approach, though with its own limitations (it misses those users whose mail
>is forwarded in /etc/aliases to external addresses like gmail.com etc.).

I have a routine that pulls addresses from all the aliases files defined in
the postfix main.cf file, and gets all non-admin accounts from /etc/passwd,
combining the two to get all valid user names. It then gets all the
domains from the postfix mydestination, combining the user names with these
domains to build a large virtual file for a border MX server that has no
users to allow it to validate incoming mail.

This have been working nicely for several years at an ISP with about 10,000
e-mail accounts. The border MX server does preliminary IP based anti-spam
and uses amavisd and clamav to scan for phishing and worms that attack the
Microsoft virus, Windows, but does no spam checking. It then sends
messages that pass amavisd to a cluster of servers that do spamassassin
checking, and delivery to NFS mounted Maildir stores.

Bill
--
INTERNET: bill@celestial.com Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
Voice: (206) 236-1676 Mercer Island, WA 98040-0820
Fax: (206) 232-9186

Fair is the most dangerous word a politician utters. Whenever a government
does something for someone, it must do something to someone.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

mouss 11-02-2008 04:39 PM

List of all email users
 
Jussi Hirvi wrote:

This is not CentOS-specific, hence OT.

I need a list of all email users on my system (there are hundreds of them).
The list could be extracted from /etc/aliases and the virtusertable.

Does anyone know of a script that would do this automatically? It would have
to
- exclude commented-out lines (of course)


and exclude "continuation" lines (lines starting with spaces).


- exclude duplicates
- produce a list of usernames (or maybe unresolved email addresses for some
users) separated by a comma


why comma? isn't LF better (one user per line)?



I imagine perl would be the way to go. I haven't used perl at all myself.



you could start with something like

getkey()
{
files=$*

for file in $files; do
sed -e '/^[# ]/d' -e '/^$/d' $file |
awk -F'[: ]' '{print $1}'
done
}

getkey /etc/aliases /etc/passwd | sort|uniq > users.local
getkey yourvirtualmap > users.virtual


If you want a list of all valid email addresses, you need to append the
domains in mydestination to users.local.

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


All times are GMT. The time now is 03:49 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.