[Mimedefang] Re: Replace with URL (updated)
Yizhar Hurwitz
yizhar at mail.com
Thu Oct 13 17:25:58 EDT 2005
HI.
I have some updates and corrections to my previous post.
Here they are (lines without the > symbol are changes from previous post).
>
> #***********************************************************************
> # %PROCEDURE: action_replace_with_comment
> # %ARGUMENTS:
> # msg -- message
> # %RETURNS:
> # Nothing
> # %DESCRIPTION:
> # Makes a note to drop the current part and replace it with a comment
> #
> # To be used in replace_with_url,
> # instead of the original replace_with_warning which is plain text only.
> #
> # Written by Yizhar Hurwitz, http://yizhar.mvps.org
> # Version 1.0 , 13-Oct-2005
> #
> #***********************************************************************
> sub action_replace_with_comment ($) {
> my($msg) = @_;
> return 0 if (!in_filter_context("action_replace_with_comment"));
> $Actions{'replace_with_warning'}++;
> $Action = "replace";
$msg =~ s/\n/<br>\n/g;
> $ReplacementEntity = MIME::Entity->build(Type => "text/html",
> Encoding => "-suggest",
> Data => [ "<html><body>\n$msg\n<\/body><\/html>\n" ]);
> $WarningCounter++;
> $ReplacementEntity->head->mime_attr("Content-Type.name" => "comment$Warning
> ounter.htm");
> $ReplacementEntity->head->mime_attr("Content-Disposition" => "inline");
> $ReplacementEntity->head->mime_attr("Content-Disposition.filename" => "comm
> nt$WarningCounter.htm");
> return 1;
> }
>
>
> === And here are the changes to the existing function replace_with_url: =============
>
> my($fname, $ext, $name, $url);
> my($htmlurl);
> my $extension = "";
> [.................]
$htmlurl = "<a href=\"$url\">$url<\/a>";
> [.................]
> $msg =~ s/_URL_/$htmlurl/g;
> action_replace_with_comment($msg);
> return 1;
>
> ==== And in "/etc/mail/mimedefang-filter" I have done the following ==============
>
> $multimedia = '(avi|mpg|mov|pps|wmv)';
> if (re_match($entity, '\.' . $multimedia)) {
> return action_replace_with_url($entity,
> "/var/tmp/mail_parts",
> "http://10.0.0.4/mail_parts",
"multimedia file converted to URL:\n_URL_\n"
> );
> }
Yizhar Hurwitz
http://yizhar.mvps.org
More information about the MIMEDefang
mailing list