On Sun, 21 May 2006, Pascal SCHIRRMANN wrote:

Here is my (non working !) plugin proto :
--------------------------------------------------------------------------------------------
!/usr/bin/perl -w
this plugin should (!) rewrite the sender address in some precise
conditions

sub hook_mail {
my ($self, $transaction, $sender) = @_;
# how can we catch the sender ?
my $newsender  = $self->qp->transaction->sender || $sender;
my $origsender = $newsender;
if ( $newsender =~ s/^(.*FETCHMAIL-DAEMON\@).+\.(schirrms\.net.*)$/$1$2/xms ) {
$transaction->header( 'From', Qpsmtpd::Address->new( $newsender ) );
return (DECLINED, "$origsender REWRITE TO $newsender");
}
return (DECLINED, "$origsender");
}
-------------------------------------------------
The plug is running, the return message tell me that $newsender is rewritten as expected, but next plugins still use $origsender.

Your plugin is only attempting to modify the headers of the message, and doesn't do anything to the envelope sender, either internally as used by qpsmtpd or when the message is queued.

To modify the header, you should be using $transaction->header->replace(). And to modify the envelope sender I think you should be using $transaction->sender($newsender);

But I agree with Gordon, you might be better off fixing the problem outside of qpsmtpd.

---
Charlie

Reply via email to