The python-script works very well with qmail-qfilter, qmail-scanner-queue
and qmail-queue !!!

Can you rewrite the script to append footer/disclaimer as text in email (not
as attachment)?

Thanks.
Leandro.

The tests are slow (my test server is poor computer, but I supose that
phthon-script is slower than C or perl).
Can anyone rewrite in C or Perl?



----- Original Message ----- 
From: "Thomas Mangin" <[EMAIL PROTECTED]>
To: "Claudio Jeker" <[EMAIL PROTECTED]>
Cc: "QMAIL-LDAP" <[EMAIL PROTECTED]>
Sent: Monday, July 26, 2004 3:29 PM
Subject: adding a footer to message passing though qmail-queue


> Hi,
>
> >Use QMAILQUEUE patch and cascade your additionally programs correctly.
> >e.g. in qmail-scanner you can configure the next "qmail-queue" that needs
> >to be started.
> >
> >
> Hope it helps.
>
> You will have to :
> 1 - compile qmail-qfilter to point to your qmail-scanner queue
> 2 - point QMAILQUEUE to the qmail-qfilter script
>
> Please report me any problem.
> If you rewrite this code in C, please let me know (I do not have the
> time to do it right now myself).
>
> Thomas
>


----------------------------------------------------------------------------
----


> #!/usr/bin/python
>
> # Copyright (C) 2004 Thomas Mangin
> # Public Domain
>
> import os
> import sys
> import re
>
> # What to append
> append_file = "footer.txt"
> append_string  = "The footer which will annoy your customers\n"
>
>
> boundary_search = '.*boundary="(.*)".*'
> boundary_string = ''
> boundary_compiled = None
>
> boundary_line = False
> append_raw = False
> append_mime = False
>
>
>
> file = os.fdopen(0)
>
>
> for line in file:
> sys.stdout.write(line)
>
> if boundary_line:
> match =  boundary_compiled.match(line)
> if match:
> boundary_string = '--' + match.group(1)
> append_mime = True
> elif len(line) > 1 and line[-2] == ';':
> continue
> break
>
>
> if line and line.startswith('Content-Type:'):
> part = line.split(':')
> if len(part) < 2:
> append_raw = False
> append_mime = False
> break
>
> if part[1].count('text/plain'):
> if append_raw:
> append_raw = False
> break
> else:
> append_raw = True
>
> elif part[1].count('multipart'):
> if part[1].count('signed'):
> break
>
> if append_raw:
> append_raw = False
> break
>
> if len(line) > 1 and line[-2] == ';':
> boundary_line = True
>
> boundary_compiled = re.compile(boundary_search)
> match =  boundary_compiled.match(line)
> if match:
> boundary_string = '--' + match.group(1)
> append_mime = True
> break
> else:
> boundary_line = True
>
>
> else:
> append_raw = False
> append_mime = False
> break
>
> end_boundary_string = boundary_string + '--'
>
> for line in file:
> if append_mime and line and line.count(end_boundary_string):
> print boundary_string
> print 'Content-Type: text/plain; charset=us-ascii; format=flowed;
name="'+append_file+'".txt"'
> print 'Content-Transfer-Encoding: 7bit'
> print
> print
> print append_string
> print end_boundary_string
> else:
> sys.stdout.write(line)
>
> if append_raw:
> print
> print append_string
>
>
> #print 'Content-Type: text/plain; charset="iso-8859-1"'
> #print 'Content-Transfer-Encoding: 8bit'
>
> file.close()
>
> sys.exit(0)
>


----------------------------------------------------------------------------
----


> #!/bin/sh
> exec /var/qmail/bin/qmail-qfilter /var/qmail/bin/qmail-qfilter-footer-mime
>

Reply via email to