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


Python Message.charset方法代码示例

本文整理汇总了Python中mailer.Message.charset方法的典型用法代码示例。如果您正苦于以下问题:Python Message.charset方法的具体用法?Python Message.charset怎么用?Python Message.charset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mailer.Message的用法示例。


在下文中一共展示了Message.charset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sendmail

# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import charset [as 别名]
def sendmail(mailto, subject, html='', text='', textfile='', htmlfile='', attachments=''):
    '''send mail'''
    if not mailto:
        print 'Error: Empty mailto address.\n'
        return

    mailto = [sb.strip() for sb in mailto.split(',')]
    if attachments:
        attachments = [att.strip() for att in attachments.split(',')] 
    else:
        attachments = []
    
    #USERNAME = hostname()
    subject = "%s-[%s]" % ( subject, hostname())

    message = Message(From=USERNAME, To=mailto, Subject=subject, attachments=attachments)
    message.Body = text
    message.Html = html
    message.charset = 'utf8'
    try:
        if htmlfile:
            message.Html += open(htmlfile, 'r').read()
        if textfile:
            message.Body += open(textfile, 'r').read()
    except IOError:
        pass

    for att in attachments:
        message.attach(att)

    sender = Mailer(SERVER,port=465, use_tls=True, usr=USERNAME, pwd=PASSWD)
    #sender = Mailer(SERVER)
    #sender.login(USERNAME, PASSWD)
    sender.send(message)
开发者ID:cychenyin,项目名称:windmill,代码行数:36,代码来源:mailman.py

示例2: Message

# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import charset [as 别名]
from mailer import Message
import urllib

msg1 = Message(From="[email protected]",
                  To=["[email protected]", "[email protected]"],
                  charset="utf-8")
msg1.Subject = "日本語のHTMLメール"
msg1.Html = """Hello, <b>日本語</b>"""

mailer = Mailer('smtp01.odn.ne.jp')

msg2 = Message(Body="ナイスボディー!", attachments=["picture.png"])
msg2.From = "[email protected]"
msg2.To = "[email protected]"
msg2.Subject = "日本語の添付ファイルメール"
msg2.charset = "utf-8"

mailer.send([msg1, msg2])

msg = Message()
msg.From = "[email protected]"
msg.To = "[email protected]"
msg.Subject = "テキストメール"
msg.Body = "これは日本語のキストメールでございます。"
msg.charset = "utf-8"
mailer.send(msg)

msg3 = Message(From="[email protected]",
                  To=["[email protected]", "[email protected]"],
                  charset="utf-8")
msg3.Subject = "HTML with Attachment"
开发者ID:arunsingh,项目名称:mailer,代码行数:33,代码来源:use_mailer.py


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