本文整理汇总了Python中Message.Message.boundary方法的典型用法代码示例。如果您正苦于以下问题:Python Message.boundary方法的具体用法?Python Message.boundary怎么用?Python Message.boundary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message.Message
的用法示例。
在下文中一共展示了Message.boundary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendmail
# 需要导入模块: from Message import Message [as 别名]
# 或者: from Message.Message import boundary [as 别名]
def sendmail(From, To, Cc=None, Bcc=None, Subject="",
Body="", File=None, Filename="", InReplyTo=None):
text = makePart(Body, "quoted-printable")
if File is not None:
data = File.read()
if data:
attach = makePart(data, "base64")
ext = os.path.splitext(Filename)[1]
ctype = mimetypes.guess_type(ext)[0] or "application/octet-stream"
attach["Content-Type"] = ctype
Filename = os.path.split(Filename)[1]
attach["Content-Disposition"] = 'attachment; filename="%s"' % Filename
msg = Message(StringIO())
msg.boundary = choose_boundary()
msg["Content-Type"] = 'multipart/mixed; boundary="%s"' % msg.boundary
msg.parts.extend([text, attach])
else: msg = text
else: msg = text
msg["From"] = From
msg["To"] = To
if Cc: msg["Cc"] = Cc
if Bcc: msg["Bcc"] = Bcc
if InReplyTo: msg["In-Reply-To"] = InReplyTo
msg["Subject"] = Subject or ""
msg["Mime-Version"] = "1.0"
text["Content-Type"] = "text/plain; charset=ISO-8859-1"
msg["X-Mailer"] = XMailer
Recipients = msg.getaddrlist("to") + msg.getaddrlist("cc") + msg.getaddrlist("bcc")
for i in range(len(Recipients)):
Recipients[i] = Recipients[i][1]
return sendMessage(From, Recipients, msg)