Le 06/05/2012 13:58, Marc SCHAEFER a écrit :
> Hi,
> 
> I have two scenarii where I would like to know how an e-mail address
> delivers. One of those scenarii is:
> 
> I extract e-mail address from various databases for the various
> services of our system (ranging from the USENET news server to
> fax to e-mail gateway) then create a (Mailman) mailing-list with it.
> Unfortunately, some of the users (including me) receive quite
> a bit of duplicates.
> 
> It could be handy to be able to remove duplicates from that
> list, e.g. by knowing what e-mail address it ultimately delivers
> to.
> 
> For example, on my big list I have:
> 
> ad...@some-domain.ch
> admi...@alphanet.ch
> www...@alphanet.ch
> fax...@alphanet.ch
> pbxad...@alphanet.ch
> 
> they all get ultimately (through /etc/aliases, vmailbox, .forward)
> to \schaefer.
> 
> sendmail -bv helps:
> 
> However, it is not easily usable in a script AFAIK.
> 
> shakotay:/home/schaefer# sendmail -bv pbxad...@alphanet.ch
> Mail Delivery Status Report will be mailed to <root>.
> 
> which then gives (among others):
> 
> <schae...@alphanet.ch> (expanded from <pbxad...@alphanet.ch>): delivery via
>     local: delivers to file: /home/schaefer/Mail/mail.received
> 
> That "schae...@alphanet.ch" is the info I need.
> 
> Is there anyway to do that, either through an installed shell command
> (Version: 2.7.1-1+squeeze1 or even a later version), or through an
> API ?
> 
> Or does the multi-threaded very confined approach of Postfix makes this
> impossible ?  In that case I could resort to heuristics, parsing
> /etc/aliases, /etc/postfix/* myself.
> 

AFAICT, there's no easy way. you could try looping over postmap -q but
that's not simple (you'll need to do everything postfix does! this
includes recursive lookups, removing the domain part for /etc/aliases
and .forward, trying multiple forms for virtual aliases - according to
the search order in the man pages. you also may need to handle '+'
addresses if they are enabled etc...). And if you do that in memory,
then you must ensure that this expansion results in a large number of
addresses.

maybe it's easier to prune duplicates at delivery time (based on the
messageId when the message is from one of your lists). you can do this
with maildrop for instance. check maildropex documentation until you see
something like this:

# Avoid messages with duplicate Message-IDs
`/usr/bin/reformail -D 8000 duplicate.cache`
if ( $RETURNCODE == 0 )
    exit

(the above applies to all mail. you may want to restrict this to your
lists mail).


> Thank you for any input!
> 
> 

Reply via email to