[Mimedefang] Idea: using action_replace_wiht_url for filetransfer
Richard Laager
rlaager at wiktel.com
Thu Jan 15 12:24:16 EST 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
JOna wrote:
> * How to do action_replace_with_url when there is a "magic word" in
> Subject-line? (and not when the attachemenet is bigger than
> something)
Match against the $Subject variable. Something like this (untested):
if ($Subject =~ /\bmagic_word\b/i)
{
# action_replace_with_url code goes here
}
The regular expression I used SHOULD (again, it's untested) match any
occurance of magic_word. The \b's are so that you don't match
magic_word as part of a longer word. The /i makes the matching
case-insentive. Obviously, change magic_word to your magic word.
> * How to create a hash-named directory instead of changing
> attachement names?
> (Attachement names can have important information that is lost if
> the attachement names are changed. That's why I can not use the
> example script at
> all in production environment.)
You don't need directories. See this page to take care of the
attachment name issue:
http://sial.org/howto/mimedefang/#s2
> * How to (in a given condition) action_replace_with_url ALL
> attachements
> instead of just the big ones?
Let's take a look at the previously posted code from the example:
$size = (stat($entity->bodyhandle->path))[7];
if ($size > 1000000) {
...
This code is getting the size of the attachment. The if statement
checks to see if the size is greater than 1000000. If you want to
strip attachment regardless of size, just don't include the code
above to check for the size. The only condition you seem to be
interested in is the Subject line. Use the if statement from the top
of this message instead.
> * How to remove some known part (magic word) from Subject-line
This is probably the code you're looking for (untested):
$new_subject = $Subject;
$new_subject =~ s/\bmagic_word\b/ /;
action_change_header("Subject", $new_subject);
I'd just like to point out, once again, this code is untested.
Hopefully it does provide a good starting point.
Richard Laager
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.2
iQA/AwUBQAbMwG31OrleHxvOEQLoKACgkrf34xSZxSGDUPR7QtpNWxe5hR0AnR73
DFXkdQtuqdCfGfXfpm8e318/
=p2x9
-----END PGP SIGNATURE-----
More information about the MIMEDefang
mailing list