қ ң ө, ө ә RFC 2822 ү ө. RFC 2822 ө қ.
, ә ө ө (ққ):
Message
Message қ - email ө ү .
Parser
құ қ ғ ә ү ү ұғ .
Header
Ө ұ , ASCII- , қ .
Generator
RFC 2822 .
Utils
ғ ә ү ү
. Message
Message email-ң қ қғ. қ қ (header) ә (payload) ұ ұ ү ә қ. қ өң ә қ ү (қ ү ғ, ә ) ө ә . Ө ә ә , ң қ. қ ө қғ ұғ ( , ұ ү ә ..) қ ү ә қғ.
, ө ұ, ң - ғ.
Message ң ө қ ә , ү:
>>> import email
>>> input_file = open("pr1.eml")
>>> msg = email.message_from_file(input_file)
ұ pr1.eml ғ қ ү email.message_from_file() қ. email.message_from_string() қ ғ . . қ ө қ :
>>> print msg['from']
"felton olive" <[email protected]>
>>> msg.get_all('received')
['from mail.onego.ru\n\tby localhost with POP3 (fetchmail-6.2.5
polling mail.onego.ru account spam)\n\tfor spam@localhost
(single-drop); Wed, 01 Sep 2004 15:46:33 +0400 (MSD)',
'from thecanadianteacher.com ([222.65.104.100])\n\tby mail.onego.ru
(8.12.11/8.12.11) with SMTP id i817UtUN026093;\n\tWed, 1 Sep 2004
11:30:58 +0400']
, received ө ү (ұ ).
|
|
ң ә ү ғ , , ұ ү, :
>>> msg.get_content_type()
'text/plain'
>>> print msg.get_main_type(), msg.get_subtype()
text plain
>>> print msg.get_charset()
None
>>> print msg.get_params()
[('text/plain', ''), ('charset', 'us-ascii')]
>>> msg.is_multipart()
False
ө :
>>> print msg.keys()
['Received', 'Received', 'Message-ID', 'Date', 'From', 'User-Agent',
'MIME-Version', 'To', 'Subject', 'Content-Type',
'Content-Transfer-Encoding', 'Spam', 'X-Spam']
ө ұғқ, ң ү ғ .
>>> print msg.get_payload()
sorgeloosheid hullw ifesh nozama decompresssequenceframes
Believe it or not, I have tried several sites to b"_"uy presription
medication. I should say that currently you are still be the best amony
...
ө ө ұ қғ. ұ ққ. ө ұ: HTML-ә ә cpl ң ғ. ң ө қ ү ң қ ө ө walk () ә қ. - ө ұ ү, Content-Type ( ct_fields) ө ә (filenames-):
import email
parts = [ ]
ct_fields = [ ]
filenames = [ ]
f = open("virus.eml")
msg = email.message_from_file(f)
for submsg in msg.walk():
parts.append(submsg.get_content_type())
ct_fields.append(submsg.get('Content-Type', ''))
filenames.append(submsg.get_filename())
if submsg.get_filename():
print " ұғ:", len(submsg.get_payload())
f.close()
print parts
print ct_fields
print filenames
ә:
ұғ: 31173
['multipart/mixed', 'text/html', 'application/octet-stream']
['multipart/mixed;\n boundary="--------hidejpxkblmvuwfplzue"',
'text/html; charset="us-ascii"',
'application/octet-stream; name="price.cpl"']
[None, None, 'price.cpl']
ө multipart/mixed ү parts ө , ң ө - text/html ә application/octet-stream ә. ңғ ө (price.cpl) . get_payload() ә қ ә ң ұғ ғ.
қ, қ ө ғ ғ, get_payload() ң ғ (ғ Message ң ).