Zivago,

> Hmm.. it's still putting the rewritten address into this field and not the
> alias that is originally sent to (rcpt to).  Just to reiterate, I am doing
> address rewriting in Postfix before the content-filter (amavisd-new)...

I didn't read your initial posting carefully, sorry.

So it seems you need to fetch ORCPT information (rfc3461) from
the SMTP protocol, assuming your version of Postfix already supports DSN.

The following patch (against amavisd-new-2.4.2) achieves that
(but I think you are trying to solve a wrong problem):



--- amavisd~    Fri Sep 29 21:12:49 2006
+++ amavisd     Thu Aug 30 01:55:31 2007
@@ -8323,4 +8323,20 @@
 }
 
+sub orcpt_decode($) {  # rfc3461
+  my($str) = @_;  # argument should be rfc3461-encoded address
+  my($addr_type,$orcpt); local($1,$2);
+  if (defined $str) {
+    if ($str =~ /^([^\000-\040\177()<>[EMAIL PROTECTED]:;,."]*);(.*\z)/si){ # 
atom;xtext
+      ($addr_type,$orcpt) = ($1,$2);
+    } else {
+      ($addr_type,$orcpt) = ('rfc822',$str);  # rfc3464 address-type
+    }
+    $orcpt = xtext_decode($orcpt);  # decode
+    $orcpt =~ s/[^\040-\176]/?/gs;  # some minimal sanitation
+  }
+  # result in $orcpt is presumably a rfc2822-encoded address, no angle brackets
+  ($addr_type,$orcpt);
+}
+
 sub add_forwarding_header_edits_common($$$$$$$$) {
   my($conn, $msginfo, $hdr_edits, $hold, $any_undecipherable,
@@ -8363,4 +8379,14 @@
   #         $Mail::SpamAssassin::SUB_VERSION, c('myhostname')));
   }
+
+  # BREAKS SENDER'S PRIVACY!!!  DO NOT USE!!!
+  my(@orcpts);
+  for my $r (@{$msginfo->per_recip_data}) {
+    my($addr_type,$orcpt) = orcpt_decode($r->dsn_orcpt);
+    $orcpt = qquote_rfc2821_local($r->recip_addr)  if !defined($orcpt);
+    push(@orcpts, $orcpt);
+  }
+  $hdr_edits->add_header('X-Original-To', join(', ',@orcpts))  if @orcpts;
+
   if ($mail_defanged ne '') {
     # prepend Resent-* header fields, they must precede corresponding Received



Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to