[Users] Collecting email addresses

Pierre Fortin pf at pfortin.com
Thu Mar 5 06:16:57 CET 2015


On Wed, 4 Mar 2015 17:54:50 +0000 Brian Morrison wrote:

>On Wed, 4 Mar 2015 09:38:46 -0800
>sylpheed at 911networks.com wrote:
>
>> Hi,
>> 
>> Is it possible to collect the email addresses that the emails that are
>> received. Not who sent it, but who they are sent to. 
>> 
>> I want to tighten the mail server and only accept email for the valid
>> users and their aliases and cut on the number of aliases.
>> 
>
>This sounds like you need to look at the mail server logs and find the
>local addresses for which you have accepted mail. That may not be
>completely perfect, but equally looking at the to address might not
>help because really you need the envelope-to: address that the SMTP
>server used to pass it on, not what is written in the To: header of the
>email. Some mail might have both, but I doubt it will be all.
>

Simple brute force should help, though some minor clean up may be
required in the final output file.

$ cd Mail/inbox  # or wherever...

$ for f in $(ls); \
  do grep -P "^\tfor " $f | cut -d " " -f 2 >> /tmp/for1; \
  done  # all on one line without trailing "\"s

$ cat /tmp/for1 | sort | uniq > /tmp/for2

HTH,
Pierre



More information about the Users mailing list