.


:




:

































 

 

 

 


қ




ғ қ ғ. ә ә құ. ү email.Message Message- ғ қ-қ, қ email.MIMEMultipart- MIMEMultipart ( ө ү), MIMEImage (қ ү), MIMEAudio ( ү), MIMEText (ә ө ү) қ:

 

# ә ү

from email.Header import make_header as mkh

from email.MIMEMultipart import MIMEMultipart

from email.MIMEText import MIMEText

from email.MIMEBase import MIMEBase

from email.Encoders import encode_base64

 

# құ ә ө

msg = MIMEMultipart()

msg["Subject"] = mkh([("", "koi8-r")])

msg["From"] = mkh([("", "koi8-r"), ("<[email protected]>", "us-ascii")])

msg["To"] = mkh([("2", "koi8-r"), ("<[email protected]>", "us-ascii")])

 

# қ ғ MIME қ , ө

msg.preamble = "Multipart message"

msg.epilogue = ""

 

# ң ә ө

text = u""" қ ұғ қ .""".encode("koi8-r")

to_attach = MIMEText(text, _charset="koi8-r")

msg.attach(to_attach)

 

#

fp = open("archive_file.zip", "rb")

to_attach = MIMEBase("application", "octet-stream")

to_attach.set_payload(fp.read())

encode_base64(to_attach)

to_attach.add_header("Content-Disposition", "attachment",

filename="archive_file.zip")

fp.close()

msg.attach(to_attach)

print msg.as_string()

 

ұ email ң ө . email.Header- make_header() қ ү ұ ғ ү .

>>> from email.Header import make_header

>>> print make_header([("", "koi8-r"), ("<[email protected]>", "us-ascii")])

=?koi8-r?b?5NLVxw==?= <[email protected]>

>>> print make_header([(u"", ""), ("<[email protected]>", "us-ascii")])

=?utf-8?b?w6TDksOVw4c=?= <[email protected]>

 

email.Encoders.encode_base64() ғ ғ қ ә base64 ө . қ ұқ: encode_quopri() quoted printable , encode_7or8bit() қ. ұ ө қ.

 

email MIME- ң :

class MIMEBase(_maintype, _subtype, **_params)

 

қ қғ MIME ң қ (Message ). ұ ү _maintype ә _subtype қ .

class MIMENonMultipart()

 

attach() ә ғ (қ ) MIMEBase ү ө ұ.

class MIMEMultipart([_subtype[, boundary[, _subparts[, _params]]]])

 

ө MIME ү қ MIMEBase ү . ү multipart, ү _subtype қ ө.

class MIMEAudio(_audiodata[, _subtype[, _encoder[, **_params]]])

 

MIMENonMultipart . ә ұ MIME құ ү қ. ү audio, ү _subtype қ ө. ә _audiodata .

class MIMEImage(_imagedata[, _subtype[, _encoder[, **_params]]])

 

MIMENonMultipart . қ MIME құ ү қ. ү image, ү _subtype қ ө. ә _imagedata қ .

class MIMEMessage(_msg[, _subtype])

 

MIMENonMultipart ү MIMENonMultipart ү message MIME құ ү қ. _msg қ ә Message ң ң ұғ . ү _subtype қ , 'rfc822' ү .

class MIMEText(_text[, _subtype[, _charset]])

 

MIMENonMultipart . ә ү MIME құ ү қ. ү text, ү _subtype қ ө. ә _text қ . _charset қ ө ('usascii' ү ).

 





:


: 2017-01-28; !; : 621 |


:

:

: , , , , .
==> ...

1306 - | 1207 -


© 2015-2024 lektsii.org - -

: 0.011 .