Also sprach Nathan E Norman: > Also, a more fair count would associate senders with user-agents ... > if I send 100 emails with mutt, and 10 other users send 10 emails each > with Outlook, which is more popular? (From a number of users > standpoint, Outlook should be the answer). Your script doesn't account > for this. >
How silly of me. Obviously I have been duped by MS agents. > Yeah, I know it was all for fun :) For fun? Have you lost mind? Don't you see what THEY are trying to do. Obviously you're an MS agent. New script, counting each sender once. (Couldn't do this in a oneliner. Maybe I'm an MS agent.) : #!/usr/bin/env python2 import mailbox, sys, re, string box = mailbox.UnixMailbox(open(sys.argv[1])) senders = {} clientscount = {} clientregexp = re.compile("(.+?)[\d,\/,\[,\.,\(].*") while 1: msg = box.next() if not msg: break sender = msg.getheader("From") if not senders.has_key(sender): senders[sender] = 1 client = msg.getheader("X-Mailer") or msg.getheader("User-Agent") or "unknown" match = clientregexp.match(client) if match: client = match.groups()[0] client = string.strip(client) if clientscount.has_key(client): clientscount[client] = clientscount[client] + 1 else: clientscount[client] = 1 results = [(key, value) for value, key in clientscount.items()] results.sort() results.reverse() for result in results: print result[1], result[0] Result. Pretty much the same. : Mutt 667 unknown 518 Mozilla 293 Microsoft Outlook Express 263 KMail 169 Gnus 105 Internet Mail Service 71 Microsoft Outlook IMO 61 Evolution 45 QUALCOMM Windows Eudora Version 38 Sylpheed version 32 Balsa 32 AOL 17 Pegasus Mail for Win 16 Microsoft Outlook 16 WWW-Mail 15 Microsoft Outlook CWS 15 VM 14 exmh version 11 IMP 11 The Bat! 10 ELM 9 SquirrelMail 8 Becky! ver 8 MIME-tools 7 XFMail 6 QUALCOMM Windows Eudora Pro Version 6 Microsoft-Outlook-Express-Macintosh-Edition 6 Forte Agent 6 Web Mail 5 Spruce 5 Mew version 5 Lotus Notes Release 5 Pronto v 4 Novell GroupWise Internet Agent 4 Mulberry 4 Gnus v 4 Windows Eudora Pro Version 3 WebMail 3 TWIG 3 Novell GroupWise 3 Mutt http: 3 EMUmail 3 tin 2 mutt-nntp 2 mailgate 2 emacs 2 Visto Server 2 Turnpike Integrated Version 2 QUALCOMM Windows Eudora Light Version 2 PocoMail 2 Opera 2 Netscape Webmail 2 NeoMail 2 NIMS ModWeb Module 2 Microsoft Outlook Express Macintosh Edition - 2 MailCity Service 2 MSN Explorer 2 InterChange 2 EMIKO 2 CommuniGate Pro Web Mailer v 2 Atlas Mailer 2 Apple Mail 2 AT&T Message Center Version 2 slrn 1 nail 1 mutt 1 mPOP Web-Mail 1 internet mail service 1 dMail 1 Windows Eudora Version 1 Windows Eudora Light Version 1 Webmin 1 Wanadoo Webmail 1 WM Professional Edition v 1 Virtual Access by Atlantic Coast PLC 1 Version 1 Unknown 1 Ultrafunk Popcorn release 1 Turnpike 1 TkMail 1 SoftForum-WebMail 1 Sequoia 1 Semi-gnus 1 RMM 1 Postaci 1 Pluto 1 Pan 1 PMMail 1 PHP 1 NMH 1 MyMAIL 1 Mutt- 1 Microsoft-Entourage 1 Microsoft Outlook Express for Macintosh - 1 Microsoft Internet Mail 1 Microsoft Internet E-mail 1 Mailsmith 1 Mailer? 1 MacSOUP 1 Lynx 1 Kaufman Mail Warrior 1 KNode 1 Juno 1 JMail 1 J 1 Interfejs WWW poczty Wirtualnej Polski 1 InMail by Insite - www 1 IMHO 1 Gmail 1 GNU Emacs 1 Forte Agent i 1 Excite Inbox 1 Endymion MailMan Standard Edition v 1 Elm 1 Edsamail 1 Daum Web Mailer 1 DMailWeb Web to Mail Gateway 1 Cronos II 1 CoreCommMail 1 CompuServe 1 Caramail - www 1 Calypso Version 1 CWMail Web to Mail Gateway 1 BeOS Mail 1 AspMail 1 AeroMail 1 <IMail v 1 2 1 "Alex Hart's Very Own Web Based Email 1 -- oivvio polite cell +46 (0)709 30 40 30 / phone +46 (0)8 669 64 18 / fax +46 (0)8 84 00 18 varvsgatan 10A / s-117 29 stockholm / sweden