[Mimedefang] conditionally add boilerplate in message with more than one recipient

Vieri Di Paola vieridipaola at gmx.com
Sat Sep 24 11:02:10 EDT 2016

> From: "Richard Laager" <rlaager at wiktel.com>
>> OK, got it. However, I want all the filtering stuff in the filter*() functions to be applied to the "resent" message to ORG, except the boilerplate. I guess it's not 
>> possible because resend_message resends the ORIGINAL message and won't be processed.
> When the message is resent, you'll see it again in another run of the
> filter. That's your opportunity to do what you need for the ORG
> recipient. Craft your filter very careful in light of this!

I'm sorry but I'm obviously doing something wrong but just don't know what.

I'm not seeing the message again in another run of the filter.
I did a simple test such as:

sub filter_end {
    my($entity) = @_;

    my($d1) = scalar(@Recipients);
    my($d2) = $Recipients[0];
    my($d3) = "";
    if (scalar(@Recipients) == 2) {
        $d3 = $Recipients[1];
    md_syslog('info', "debug_resendmsg_d1_${d1}_${Subject}");
    md_syslog('info', "debug_resendmsg_d2_${d2}_${Subject}");
    md_syslog('info', "debug_resendmsg_d3_${d3}_${Subject}");
    if ($d1 == 2 && $d2 eq '<user at domain.com>' && $d3 eq '<user at domain.org>') {
<------>md_syslog('info', "debug_resendmsg_match_${Subject}");
<------>if (resend_message($d3)) {
<------>    delete_recipient($d3);
<------>    md_syslog('info', "debug_resendmsg_resent_and_deleted_$d3");


I then sent an email to "user at domain.com, user at domain.org", grepped the log and found:

# tail -n 10000 /var/log/messages | grep debug_resendmsg
mimedefang.pl[16650]: DFB4B35E3265: debug_resendmsg_d1_2_test 1
mimedefang.pl[16650]: DFB4B35E3265: debug_resendmsg_d2_<user at domain.com>_test 1
mimedefang.pl[16650]: DFB4B35E3265: debug_resendmsg_d3_<user at domain.org>_test 1
mimedefang.pl[16650]: DFB4B35E3265: debug_resendmsg_match_test 1
mimedefang.pl[16858]: DFB4B35E3265: debug_resendmsg_sendmail: /usr/sbin/sendmail -f<fromuser at domain.net> -odd -Ac -oi -- <user at domain.org>
mimedefang.pl[16650]: DFB4B35E3265: debug_resendmsg_resent_and_deleted_<user at domain.org>

If I remove the custom "if" clause from filter_end() and send another e-mail then this is what I get in the log (no call to resend_message):

mimedefang.pl[22093]: 7274235E33E7: debug_resendmsg_d1_2_test 2
mimedefang.pl[22093]: 7274235E33E7: debug_resendmsg_d2_<user at domain.com>_test 2
mimedefang.pl[22093]: 7274235E33E7: debug_resendmsg_d3_<user at domain.org>_test 2

So since I'm getting the same number of lines on the log regarding "debug_resendmsg_d{1,2,3}" then I'm assuming I'm getting just one run through the filter.

BTW I also tried running this command manually and it worked fine (I could send an e-mail correctly):
/usr/sbin/sendmail -f<fromuser at domain.net> -odd -Ac -oi -- <user at domain.org>

Like I said before, I'm using Postfix but the sendmail interface seems to work fine.

What am I doing wrong?


More information about the MIMEDefang mailing list