當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。