Documentation

NAME

Mail::MIMEDefang::MIME - MIME objects interface methods for email filters

DESCRIPTION

Mail::MIMEDefang::MIME are a set of methods that can be called from mimedefang-filter to operate on MIME objects.

METHODS

  • collect_parts

    Method that adds parts to the array @FlatParts for flattening.

  • takeStabAtFilename ( $entity )

    Makes a guess at a filename for the attachment. Calls MIME::Head's recommended_filename() method, which tries 'Content-Disposition.filename'and if not found, 'Content-Type.name'.

    Returns a MIME-decoded filename, or a blank string if none found.

  • find_part

    Method that returns the first MIME entity of type $content_type, undef if none exists.

  • append_to_part

    Method that appends text to $part

  • remove_redundant_html_parts

    Method that rebuilds the email message without redundant HTML parts. That is, if a multipart/alternative entity contains text/plain and text/html parts, the text/html part will be removed.

  • append_to_html_part

    Method that appends text to the specified mime part, but does so by parsing HTML and adding the text before </body> or </html> tags.

  • append_text_boilerplate

    Method that appends text to text/plain part or parts.

  • append_html_boilerplate

    Method that appends text to text/html part or parts. It tries to be clever and inserts the text before the </body> tag to be able of being seen.

  • anonymize_uri

    Anonymize urls by removing all utm_* parameters, takes the message part as parameter and returns a boolean value if the sub succeeded or not.

  • md_concatenated_base64

    Returns 1 if the message being filtered has at least one base64-encoded part made of several base64 streams glued together (data follows a padding character), and 0 otherwise. RFC 2045 does not allow this; some mail clients decode each stream separately and join the results, others decode the part as a single stream. MIMEDefang logs a warning when it sees such a part.

    Legitimate mail from buggy software can trigger this, so consider tagging or quarantining rather than rejecting. For example:

    sub filter_begin {
        my ($entity) = @_;
        if (md_concatenated_base64()) {
            action_quarantine_entire_message('Base64 part with concatenated streams');
        }
    }
    
  • md_mime_suspicious

    Returns 1 if MIME-tools reported the message being filtered as ambiguous (for example, repeated Content-Type or Content-Transfer-Encoding headers, or repeated or empty parameters), so that mail clients may interpret it differently, and 0 otherwise. Always returns 0 if the installed MIME-tools cannot report this. MIMEDefang logs a warning for such messages.