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


Python utils.DNS_NAME属性代码示例

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


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

示例1: message

# 需要导入模块: from django.core.mail import utils [as 别名]
# 或者: from django.core.mail.utils import DNS_NAME [as 别名]
def message(self):
        encoding = self.encoding or settings.DEFAULT_CHARSET
        msg = SafeMIMEText(self.body, self.content_subtype, encoding)
        msg = self._create_message(msg)
        msg['Subject'] = self.subject
        msg['From'] = self.extra_headers.get('From', self.from_email)
        msg['To'] = self.extra_headers.get('To', ', '.join(map(force_text, self.to)))
        if self.cc:
            msg['Cc'] = ', '.join(map(force_text, self.cc))
        if self.reply_to:
            msg['Reply-To'] = self.extra_headers.get('Reply-To', ', '.join(map(force_text, self.reply_to)))

        # Email header names are case-insensitive (RFC 2045), so we have to
        # accommodate that when doing comparisons.
        header_names = [key.lower() for key in self.extra_headers]
        if 'date' not in header_names:
            msg['Date'] = formatdate()
        if 'message-id' not in header_names:
            # Use cached DNS_NAME for performance
            msg['Message-ID'] = make_msgid(domain=DNS_NAME)
        for name, value in self.extra_headers.items():
            if name.lower() in ('from', 'to'):  # From and To are already handled
                continue
            msg[name] = value
        return msg 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:27,代码来源:message.py

示例2: message

# 需要导入模块: from django.core.mail import utils [as 别名]
# 或者: from django.core.mail.utils import DNS_NAME [as 别名]
def message(self):
        encoding = self.encoding or settings.DEFAULT_CHARSET
        msg = SafeMIMEText(self.body, self.content_subtype, encoding)
        msg = self._create_message(msg)
        msg['Subject'] = self.subject
        msg['From'] = self.extra_headers.get('From', self.from_email)
        msg['To'] = self.extra_headers.get('To', ', '.join(self.to))
        if self.cc:
            msg['Cc'] = ', '.join(self.cc)
        if self.reply_to:
            msg['Reply-To'] = self.extra_headers.get('Reply-To', ', '.join(self.reply_to))

        # Email header names are case-insensitive (RFC 2045), so we have to
        # accommodate that when doing comparisons.
        header_names = [key.lower() for key in self.extra_headers]
        if 'date' not in header_names:
            msg['Date'] = formatdate()
        if 'message-id' not in header_names:
            # Use cached DNS_NAME for performance
            msg['Message-ID'] = make_msgid(domain=DNS_NAME)
        for name, value in self.extra_headers.items():
            if name.lower() in ('from', 'to'):  # From and To are already handled
                continue
            msg[name] = value
        return msg 
开发者ID:0daybug,项目名称:DjangoBlog,代码行数:27,代码来源:message.py

示例3: make_msgid

# 需要导入模块: from django.core.mail import utils [as 别名]
# 或者: from django.core.mail.utils import DNS_NAME [as 别名]
def make_msgid(idstring=None, domain=None):
    """Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <[email protected]>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    """
    timeval = time.time()
    utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))
    pid = os.getpid()
    randint = random.randrange(100000)
    if idstring is None:
        idstring = ''
    else:
        idstring = '.' + idstring
    if domain is None:
        # stdlib uses socket.getfqdn() here instead
        domain = DNS_NAME
    msgid = '<%s.%s.%s%[email protected]%s>' % (utcdate, pid, randint, idstring, domain)
    return msgid


# Header names that contain structured address data (RFC #5322) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:28,代码来源:message.py

示例4: make_msgid

# 需要导入模块: from django.core.mail import utils [as 别名]
# 或者: from django.core.mail.utils import DNS_NAME [as 别名]
def make_msgid(idstring=None, domain=None):
    """Returns a string suitable for RFC 5322 compliant Message-ID, e.g:

    <[email protected]>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    """
    timeval = time.time()
    utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))
    pid = os.getpid()
    randint = random.randrange(100000)
    if idstring is None:
        idstring = ''
    else:
        idstring = '.' + idstring
    if domain is None:
        # stdlib uses socket.getfqdn() here instead
        domain = DNS_NAME
    msgid = '<%s.%s.%s%[email protected]%s>' % (utcdate, pid, randint, idstring, domain)
    return msgid


# Header names that contain structured address data (RFC #5322) 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:28,代码来源:message.py

示例5: message

# 需要导入模块: from django.core.mail import utils [as 别名]
# 或者: from django.core.mail.utils import DNS_NAME [as 别名]
def message(self):
        encoding = self.encoding or settings.DEFAULT_CHARSET
        msg = SafeMIMEText(self.body, self.content_subtype, encoding)
        msg = self._create_message(msg)
        msg['Subject'] = self.subject
        msg['From'] = self.extra_headers.get('From', self.from_email)
        msg['To'] = self.extra_headers.get('To', ', '.join(map(force_text, self.to)))
        if self.cc:
            msg['Cc'] = ', '.join(map(force_text, self.cc))
        if self.reply_to:
            msg['Reply-To'] = self.extra_headers.get('Reply-To', ', '.join(map(force_text, self.reply_to)))

        # Email header names are case-insensitive (RFC 2045), so we have to
        # accommodate that when doing comparisons.
        header_names = [key.lower() for key in self.extra_headers]
        if 'date' not in header_names:
            # formatdate() uses stdlib methods to format the date, which use
            # the stdlib/OS concept of a timezone, however, Django sets the
            # TZ environment variable based on the TIME_ZONE setting which
            # will get picked up by formatdate().
            msg['Date'] = formatdate(localtime=settings.EMAIL_USE_LOCALTIME)
        if 'message-id' not in header_names:
            # Use cached DNS_NAME for performance
            msg['Message-ID'] = make_msgid(domain=DNS_NAME)
        for name, value in self.extra_headers.items():
            if name.lower() in ('from', 'to'):  # From and To are already handled
                continue
            msg[name] = value
        return msg 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:31,代码来源:message.py


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