forked from jkocherhans/maillib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
56 lines (47 loc) · 1.63 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
maillib
=======
maillib is a wrapper around Python's email package to provide simple and
automatic decoding of messages to unicode and several other conveniences.
Example
=======
>>> import maillib
>>> import datetime
>>>
>>> RAW_MESSAGE = """\
... MIME-version: 1.0
... Date: Sun, 25 Oct 2009 21:12:18 -0500
... Message-id: <[email protected]>
... Subject: =?UTF-8?B?0JLQsNGI0YMg0LzRi9GB0LvRjA==?=
... From: Sender <[email protected]>
... To: =?UTF-8?B?0JLQu9Cw0LTQuMyB0LzQuNGAINCc0LDRj9C60L7MgdCy0YHQutC40Lk=?=
... <[email protected]>
... Content-type: multipart/alternative; boundary=001636ed670f4e3ad20476cd176b
...
... --001636ed670f4e3ad20476cd176b
... Content-Type: text/plain; charset=UTF-8
... Content-Transfer-Encoding: base64
...
... KtGB0L/QsNGB0LjQsdC+Kgo=
... --001636ed670f4e3ad20476cd176b
... Content-Type: text/html; charset=UTF-8
... Content-Transfer-Encoding: quoted-printable
...
... <span class=3D"Apple-style-span" style=3D"font-family: arial, sans-serif; f=
... ont-size: 13px; border-collapse: collapse; "><b>=D1=81=D0=BF=D0=B0=D1=81=D0=
... =B8=D0=B1=D0=BE</b></span>
...
... --001636ed670f4e3ad20476cd176b--
... """
>>> msg = maillib.Message.from_string(RAW_MESSAGE)
>>> msg.subject
Вашу мысль
>>> msg.sender
(u'Sender', u'[email protected]')
>>> msg.to
(u'Влади́мир Маяко́вский' u'[email protected]')
>>> msg.date
datetime.datetime(2009, 10, 26, 2, 12, 18)
>>> msg.body
спасибо
>>> msg.html
<span class=3D"Apple-style-span" style=3D"font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><b>спасибо</b></span>