<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Zdravim,<br>
<br>
dodavam klientovi skript pro stazeni mailu z POP3, preformatovani a
odeslani pres SMTP. Touto metodou beru z puvodniho mailu textovou
cast:<br>
<blockquote><small><tt>def get_email_text(self, msg):</tt><br>
<tt> """</tt><br>
<tt> get plaintext part of the message, or None if none</tt><br>
<tt> """</tt><br>
<tt> get_charset = lambda msg: msg.get_content_charset() or
msg.get_charset() or 'ascii'</tt><br>
<tt> get_payload = lambda msg:
unicode(msg.get_payload(decode=True), get_charset(msg),
'replace')</tt><br>
<br>
<tt> maintype = msg.get_content_maintype()</tt><br>
<tt> if maintype == 'multipart':</tt><br>
<tt> return u'\n'.join(get_payload(part) for part in
typed_subpart_iterator(msg, 'text', 'plain'))</tt><br>
<tt> elif maintype == 'text':</tt><br>
<tt> return get_payload(msg)</tt><br>
<tt> else:</tt><br>
<tt> return None</tt><br>
</small></blockquote>
<br>
U me na Ubuntu 12.04.3 LTS s Python 2.7 i na Debian Squeeze s Python
2.6 se maily zpracuji dobre. Zahlavi hlavni casti zdrojaku
vysledneho mailu a dobre kodovany vyraz "odlozeni trestniho
oznameni":<br>
<blockquote><small><tt>Content-Type: text/html; charset="utf-8"</tt><br>
<tt>MIME-Version: 1.0</tt><br>
<tt>Content-Transfer-Encoding: quoted-printable</tt><br>
<br>
<tt>odlo=C5=BEen=C3=AD trestn=C3=ADho ozn=C3=A1men=C3=AD</tt></small><br>
</blockquote>
<br>
Nicmene u klienta na Ubuntu 10.04 LTS s Python 2.6 maji vsechny
maily diakritiku poskozenou, opet zahlavi s stejne slovo blbe
kodovane:<br>
<blockquote><small><tt>Content-Type: text/html; charset="utf-8"</tt></small><br>
<small><tt>MIME-Version: 1.0</tt></small><br>
<small><tt>Content-Transfer-Encoding: quoted-printable</tt></small><br>
<br>
<small><tt>odlo=17Een=ED trestn=EDho ozn=E1men=ED</tt></small><br>
</blockquote>
<br>
Vim, ze 10.04 je dost stara verze, ale takhle zlobit? Zaslal mi
vypis promennych prostredi, nevidim tam nic podezreleho.<br>
<br>
Nesetkal se nekdo z vas s necim podobnym?<br>
<br>
Diky predem,<br>
<br>
Vlada<br>
<br>
</body>
</html>