当前位置: 首页>>代码示例>>Python>>正文


Python Message.boundary方法代码示例

本文整理汇总了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)
开发者ID:MinasAbrahamyan,项目名称:bobomail,代码行数:33,代码来源:sendmail.py


注:本文中的Message.Message.boundary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。