HylaFAX The world's
most advanced open source fax server
|
|
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
[hylafax-users] RFC2047-encoded Subject and Payload fields (corrected)
- To: "hylaFax Mailing liste" <hylafax-users@xxxxxxxxxxx>
- Subject: [hylafax-users] RFC2047-encoded Subject and Payload fields (corrected)
- From: "Marcello Golfieri" <golfieri@xxxxxxxxx>
- Date: Wed, 27 Jun 2007 12:19:47 +0200
I wrote a python script handling accents by substituting them with
quotes and backquotes (don't ask me why, but faxmail gets mad when
using backquotes in the subject field, while quotes give other kind of
problems in the payload... who knows!)
In case I'll have some spare time, I'll try working on the C code
of faxmail itself. Also because I tried passing quoted printable chars
in faxmail utf-ed, but it doesn't handle them, as Lee noticed.
Notice
that this script acts like a filter, so you use it by means of its std
IO. You can call it in a script that is in Postfix conf file
master.cf, in a line that pretty much goes:
cat | /usr/bin/RFC2047decoder.py > /usr/local/bin/faxmail -t done -s a4 -d $RECIPIENT $SEN
DER
Here's RFC2047decoder.py
:
#!/usr/bin/python
# -*- coding: latin-1 -*-
#RFC2047decoder.py
#v1.0
#Marcello Golfieri
import email
import sys
import quopri
Email=email.message_from_string(sys.stdin.read())
payload=
Email.get_payload()
subject=Email.get("Subject").strip()
accents={'à':"a'",'è':"e'",'é':"e'",'ì':"i'",'ò':"o'",'ù':"u'"}
accentspayload={'à':"a`",'è':"e`",'é':"e`",'ì':"i`",'ò':"o`",'ù':"u`"}
if subject.startswith('=?utf-8?'):
subj=quopri.decodestring(subject[10:-2])
for i in accents:
subj=subj.replace(i,accents[i])
Email.replace_header("Subject",subj.replace("_"," "))
payload=quopri.decodestring(str(payload))
for i in accents:
payload=payload.replace(i,accentspayload[i])
Email.set_payload(payload)
sys.stdout.write(Email.as_string())
--
Marcello Golfieri