當前位置: 首頁>>代碼示例>>Python>>正文


Python MIMEText.__init__方法代碼示例

本文整理匯總了Python中email.mime.text.MIMEText.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python MIMEText.__init__方法的具體用法?Python MIMEText.__init__怎麽用?Python MIMEText.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在email.mime.text.MIMEText的用法示例。


在下文中一共展示了MIMEText.__init__方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from email.mime.text import MIMEText [as 別名]
# 或者: from email.mime.text.MIMEText import __init__ [as 別名]
def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
            connection=None, attachments=None, headers=None, alternatives=None,
            cc=None, reply_to=None):
        """
        Initialize a single email message (which can be sent to multiple
        recipients).

        All strings used to create the message can be unicode strings (or UTF-8
        bytestrings). The SafeMIMEText class will handle any necessary encoding
        conversions.
        """
        super(EmailMultiAlternatives, self).__init__(
            subject, body, from_email, to, bcc, connection, attachments,
            headers, cc, reply_to,
        )
        self.alternatives = alternatives or [] 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:18,代碼來源:message.py

示例2: __init__

# 需要導入模塊: from email.mime.text import MIMEText [as 別名]
# 或者: from email.mime.text.MIMEText import __init__ [as 別名]
def __init__(self, _text, _subtype='plain', _charset=None):
        self.encoding = _charset
        if _charset == 'utf-8':
            # Unfortunately, Python < 3.5 doesn't support setting a Charset instance
            # as MIMEText init parameter (http://bugs.python.org/issue16324).
            # We do it manually and trigger re-encoding of the payload.
            MIMEText.__init__(self, _text, _subtype, None)
            del self['Content-Transfer-Encoding']
            has_long_lines = any(len(l) > RFC5322_EMAIL_LINE_LENGTH_LIMIT for l in _text.splitlines())
            # Quoted-Printable encoding has the side effect of shortening long
            # lines, if any (#22561).
            self.set_payload(_text, utf8_charset_qp if has_long_lines else utf8_charset)
            self.replace_header('Content-Type', 'text/%s; charset="%s"' % (_subtype, _charset))
        elif _charset is None:
            # the default value of '_charset' is 'us-ascii' on Python 2
            MIMEText.__init__(self, _text, _subtype)
        else:
            MIMEText.__init__(self, _text, _subtype, _charset) 
開發者ID:KimJangHyeon,項目名稱:NarshaTech,代碼行數:20,代碼來源:message.py

示例3: __init__

# 需要導入模塊: from email.mime.text import MIMEText [as 別名]
# 或者: from email.mime.text.MIMEText import __init__ [as 別名]
def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
                 connection=None, attachments=None, headers=None, alternatives=None,
                 cc=None, reply_to=None):
        """
        Initialize a single email message (which can be sent to multiple
        recipients).

        All strings used to create the message can be unicode strings (or UTF-8
        bytestrings). The SafeMIMEText class will handle any necessary encoding
        conversions.
        """
        super(EmailMultiAlternatives, self).__init__(
            subject, body, from_email, to, bcc, connection, attachments,
            headers, cc, reply_to,
        )
        self.alternatives = alternatives or [] 
開發者ID:prakharchoudhary,項目名稱:Scrum,代碼行數:18,代碼來源:message.py

示例4: __init__

# 需要導入模塊: from email.mime.text import MIMEText [as 別名]
# 或者: from email.mime.text.MIMEText import __init__ [as 別名]
def __init__(self, _text, _subtype='plain', _charset=None):
        self.encoding = _charset
        if _charset == 'utf-8':
            # Unfortunately, Python < 3.5 doesn't support setting a Charset instance
            # as MIMEText init parameter (http://bugs.python.org/issue16324).
            # We do it manually and trigger re-encoding of the payload.
            MIMEText.__init__(self, _text, _subtype, None)
            del self['Content-Transfer-Encoding']
            # Workaround for versions without http://bugs.python.org/issue19063
            if (3, 2) < sys.version_info < (3, 3, 4):
                payload = _text.encode(utf8_charset.output_charset)
                self._payload = payload.decode('ascii', 'surrogateescape')
                self.set_charset(utf8_charset)
            else:
                self.set_payload(_text, utf8_charset)
            self.replace_header('Content-Type', 'text/%s; charset="%s"' % (_subtype, _charset))
        elif _charset is None:
            # the default value of '_charset' is 'us-ascii' on Python 2
            MIMEText.__init__(self, _text, _subtype)
        else:
            MIMEText.__init__(self, _text, _subtype, _charset) 
開發者ID:0daybug,項目名稱:DjangoBlog,代碼行數:23,代碼來源:message.py

示例5: __init__

# 需要導入模塊: from email.mime.text import MIMEText [as 別名]
# 或者: from email.mime.text.MIMEText import __init__ [as 別名]
def __init__(self, _text, _subtype='plain', _charset=None):
        self.encoding = _charset
        if _charset == 'utf-8':
            # Unfortunately, Python doesn't yet pass a Charset instance as
            # MIMEText init parameter to set_payload().
            # http://bugs.python.org/issue27445
            # We do it manually and trigger re-encoding of the payload.
            if six.PY3 and isinstance(_text, bytes):
                # Sniffing encoding would fail with bytes content in MIMEText.__init__.
                _text = _text.decode('utf-8')
            MIMEText.__init__(self, _text, _subtype, None)
            del self['Content-Transfer-Encoding']
            has_long_lines = any(len(l) > RFC5322_EMAIL_LINE_LENGTH_LIMIT for l in _text.splitlines())
            # Quoted-Printable encoding has the side effect of shortening long
            # lines, if any (#22561).
            self.set_payload(_text, utf8_charset_qp if has_long_lines else utf8_charset)
            self.replace_header('Content-Type', 'text/%s; charset="%s"' % (_subtype, _charset))
        elif _charset is None:
            # the default value of '_charset' is 'us-ascii' on Python 2
            MIMEText.__init__(self, _text, _subtype)
        else:
            MIMEText.__init__(self, _text, _subtype, _charset) 
開發者ID:MTG,項目名稱:lifesoundtrack,代碼行數:24,代碼來源:message.py

示例6: __init__

# 需要導入模塊: from email.mime.text import MIMEText [as 別名]
# 或者: from email.mime.text.MIMEText import __init__ [as 別名]
def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
                 connection=None, attachments=None, headers=None, alternatives=None,
                 cc=None, reply_to=None):
        """
        Initialize a single email message (which can be sent to multiple
        recipients).

        All strings used to create the message can be unicode strings (or UTF-8
        bytestrings). The SafeMIMEText class will handle any necessary encoding
        conversions.
        """

        to = self.clean_list(to)

        super(EmailMultiAlternatives, self).__init__(
            subject, body, from_email, to, bcc, connection, attachments,
            headers, cc, reply_to,
        )
        self.alternatives = alternatives or [] 
開發者ID:CMSgov,項目名稱:bluebutton-web-server,代碼行數:21,代碼來源:message.py


注:本文中的email.mime.text.MIMEText.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。