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


Python DNS_NAME.get_fqdn方法代码示例

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


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

示例1: open

# 需要导入模块: from django.core.mail.utils import DNS_NAME [as 别名]
# 或者: from django.core.mail.utils.DNS_NAME import get_fqdn [as 别名]
def open(self):
        """
        Ensures we have a connection to the email server. Returns whether or
        not a new connection was required (True or False).
        """
        if self.connection:
            # Nothing to do if the connection is already open.
            return False
        try:
            # If local_hostname is not specified, socket.getfqdn() gets used.
            # For performance, we use the cached FQDN for local_hostname.
            self.connection = smtplib.SMTP(self.host, self.port,
                                           local_hostname=DNS_NAME.get_fqdn())
            if self.use_tls:
                self.connection.ehlo()
                self.connection.starttls()
                self.connection.ehlo()
            if self.username and self.password:
                self.connection.login(self.username, self.password)
            return True
        except:
            if not self.fail_silently:
                raise 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:25,代码来源:smtp.py

示例2: open

# 需要导入模块: from django.core.mail.utils import DNS_NAME [as 别名]
# 或者: from django.core.mail.utils.DNS_NAME import get_fqdn [as 别名]
def open(self):
        """
        Ensures we have a connection to the email server. Returns whether or
        not a new connection was required (True or False).
        """
        if self.connection:
            # Nothing to do if the connection is already open.
            return False

        connection_class = smtplib.SMTP_SSL if self.use_ssl else smtplib.SMTP
        # If local_hostname is not specified, socket.getfqdn() gets used.
        # For performance, we use the cached FQDN for local_hostname.
        connection_params = {'local_hostname': DNS_NAME.get_fqdn()}
        if self.timeout is not None:
            connection_params['timeout'] = self.timeout
        if self.use_ssl:
            connection_params.update({
                'keyfile': self.ssl_keyfile,
                'certfile': self.ssl_certfile,
            })
        try:
            self.connection = connection_class(self.host, self.port, **connection_params)

            # TLS/SSL are mutually exclusive, so only attempt TLS over
            # non-secure connections.
            if not self.use_ssl and self.use_tls:
                self.connection.ehlo()
                self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
                self.connection.ehlo()
            if self.username and self.password:
                self.connection.login(self.username, self.password)
            return True
        except smtplib.SMTPException:
            if not self.fail_silently:
                raise 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:37,代码来源:smtp.py

示例3: open

# 需要导入模块: from django.core.mail.utils import DNS_NAME [as 别名]
# 或者: from django.core.mail.utils.DNS_NAME import get_fqdn [as 别名]
def open(self):
        """
        Ensure an open connection to the email server. Return whether or not a
        new connection was required (True or False) or None if an exception
        passed silently.
        """
        if self.connection:
            # Nothing to do if the connection is already open.
            return False

        # If local_hostname is not specified, socket.getfqdn() gets used.
        # For performance, we use the cached FQDN for local_hostname.
        connection_params = {'local_hostname': DNS_NAME.get_fqdn()}
        if self.timeout is not None:
            connection_params['timeout'] = self.timeout
        if self.use_ssl:
            connection_params.update({
                'keyfile': self.ssl_keyfile,
                'certfile': self.ssl_certfile,
            })
        try:
            self.connection = self.connection_class(self.host, self.port, **connection_params)

            # TLS/SSL are mutually exclusive, so only attempt TLS over
            # non-secure connections.
            if not self.use_ssl and self.use_tls:
                self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
            if self.username and self.password:
                self.connection.login(force_str(self.username), force_str(self.password))
            return True
        except (smtplib.SMTPException, socket.error):
            if not self.fail_silently:
                raise 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:35,代码来源:smtp.py

示例4: open

# 需要导入模块: from django.core.mail.utils import DNS_NAME [as 别名]
# 或者: from django.core.mail.utils.DNS_NAME import get_fqdn [as 别名]
def open(self):
        """
        Ensure an open connection to the email server. Return whether or not a
        new connection was required (True or False) or None if an exception
        passed silently.
        """
        if self.connection:
            # Nothing to do if the connection is already open.
            return False

        # If local_hostname is not specified, socket.getfqdn() gets used.
        # For performance, we use the cached FQDN for local_hostname.
        connection_params = {'local_hostname': DNS_NAME.get_fqdn()}
        if self.timeout is not None:
            connection_params['timeout'] = self.timeout
        if self.use_ssl:
            connection_params.update({
                'keyfile': self.ssl_keyfile,
                'certfile': self.ssl_certfile,
            })
        try:
            self.connection = self.connection_class(self.host, self.port, **connection_params)

            # TLS/SSL are mutually exclusive, so only attempt TLS over
            # non-secure connections.
            if not self.use_ssl and self.use_tls:
                self.connection.ehlo()
                self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
                self.connection.ehlo()
            if self.username and self.password:
                self.connection.login(force_str(self.username), force_str(self.password))
            return True
        except (smtplib.SMTPException, socket.error):
            if not self.fail_silently:
                raise 
开发者ID:MTG,项目名称:lifesoundtrack,代码行数:37,代码来源:smtp.py


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