[Mimedefang] replace_entire_message() help

Michael Fox news at mefox.org
Fri Nov 17 10:46:00 EST 2017


I need some help with the replace_entire_message() function.  Apologies in
advance if the problem is my novice perl knowledge.

Assume $entity is the existing entity and $new_entity is the newly built
entity.

1) When building $new_entity, does every field need to be included?  Or will
extra info be copied from the existing $entity?  For example, suppose I have
the following in filter_end():

    $new_entity = MIME::Entity->build(
        Subject => $foo,
        Data    => $bar,
    );

Do I also need to specifically set Bcc, Cc, Date, From, Message-ID, etc.
equal to the corresponding $entity values?  Or will the extra fields be
copied from $entity?


2)  I can't figure out how to replace the Subject header - even with a
string literal.  For example, suppose I have the following in filter_end():

    $new_subject = 'Replacement Subject';
    $new_body    = 'Replacement Body';
    $new_entity = MIME::Entity->build(
        Type    => 'text/plain',
        Subject => $new_subject,
        Data    => $new_body,
    );
    replace_entire_message($new_entity);

What comes through the filter (received in the user's mailbox) is a
text/plain message with the original subject and the replacement body.  What
am I doing wrong?

Thanks,
Michael

    




More information about the MIMEDefang mailing list