[Mimedefang] $Sender -> Return-Path

Fredrik Pettai pettai at nordu.net
Tue Nov 18 06:01:27 EST 2014


We have a simple filter function that looks at $Sender (for a group senders addresses) and in the subject or body (for a specific word), and if both the criterias are true then the $Subject is altered (a prefix is added).

sub filter {
    my($entity, $fname, $ext, $type) = @_;

    return if message_rejected(); # Avoid unnecessary work

    if ($Sender =~ /(\<?kamelasa\@example\.net\>?|\<?syggelekokle\@example\.net\>?)/) {
        if ($Subject =~ /MATCHINGSTRING/i) {
            action_change_header('Subject', "[PREFIX]$Subject");
        } else {
            my $io;
            if ($io = $entity->open("r")) {
                while (defined($_ = $io->getline)) {
                    if (/MATCHINGSTRING/i) {
                        action_change_header('Subject', "[PREFIX]$Subject");
    return action_accept();

We noted that this filter function didn't work although both the criterias seemed to be true. It turns out that $Sender isn't the email address of From: header in those cases, instead $Sender is set to the email address of the Return-Path header. Maybe this has always been the case, and we where just lucky until now…

I guess the question is if it's possible to avoid having Return-Path ending up in $Sender, or if we should do the matching against "$Sender" (or something else) in a different way? (We don't want to put in all possible Return-Path email addresses in the $Sender matching)     


More information about the MIMEDefang mailing list