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


Python smtplib.SMTP_PORT屬性代碼示例

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


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

示例1: __init__

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def __init__(self, host="localhost",
                 port=smtplib.SMTP_PORT,
                 debugLevel=0,
                 mailFrom="localhost@localhost",
                 mailTo="localhost@localhost",
                 username="",
                 password=""):
        Publisher.__init__(self)
        self.host = host
        try:
            self.port = int(port)
        except:
            raise PeachException("The SMTP publisher parameter for port is not a valid number.")
        self.debugLevel = int(debugLevel)
        self.mailFrom = mailFrom
        self.mailTo = mailTo
        self.username = username
        self.password = password
        self.loadBalance = 0
        self._connected = None 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:22,代碼來源:smtp.py

示例2: __init__

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def __init__(self, host = '', port = 0, local_hostname = None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
        self.default_port = smtplib.SMTP_PORT
        self.stream = None
        self.timeout = timeout
        #self.sock = None
        self.esmtp_features = {}
        self.host = host
        self.port = port

        if local_hostname: 
            self.local_hostname = local_hostname 
        else:
            fqdn = socket.getfqdn() 
            if '.' in fqdn:
                self.local_hostname = bytes(fqdn, 'utf-8') 
            else: 
                addr = '127.0.0.1' 
                try: 
                    addr = socket.gethostbyname(socket.gethostname())
                except socket.gaierror: 
                    pass 
                self.local_hostname = bytes('[%s]' % addr, 'utf-8') 
開發者ID:vuamitom,項目名稱:tornado-smtpclient,代碼行數:24,代碼來源:client.py

示例3: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        """
        try:
            import smtplib
            from email.utils import formatdate
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port, timeout=self.timeout)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                            self.fromaddr,
                            ",".join(self.toaddrs),
                            self.getSubject(record),
                            formatdate(), msg)
            if self.username:
                if self.secure is not None:
                    smtp.ehlo()
                    smtp.starttls(*self.secure)
                    smtp.ehlo()
                smtp.login(self.username, self.password)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit): #pragma: no cover
            raise
        except:
            self.handleError(record) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:33,代碼來源:handlers.py

示例4: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        """
        try:
            import smtplib
            from email.utils import formatdate
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                            self.fromaddr,
                            ",".join(self.toaddrs),
                            self.getSubject(record),
                            formatdate(), msg)
            if self.username:
                if self.secure is not None:
                    smtp.ehlo()
                    smtp.starttls(*self.secure)
                    smtp.ehlo()
                smtp.login(self.username, self.password)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:33,代碼來源:handlers.py

示例5: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        """
        try:
            import smtplib
            from email.utils import formatdate
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port, timeout=self._timeout)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                            self.fromaddr,
                            ",".join(self.toaddrs),
                            self.getSubject(record),
                            formatdate(), msg)
            if self.username:
                if self.secure is not None:
                    smtp.ehlo()
                    smtp.starttls(*self.secure)
                    smtp.ehlo()
                smtp.login(self.username, self.password)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:33,代碼來源:handlers.py

示例6: __emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def __emit(self, record):
        # noinspection PyBroadException
        try:
            import smtplib
            from email.message import EmailMessage
            import email.utils
            t_start = time.time()
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP_SSL(self.mailhost, port, timeout=self.timeout) if self._is_use_ssl else smtplib.SMTP(
                self.mailhost, port, timeout=self.timeout)
            msg = EmailMessage()
            msg['From'] = self.fromaddr
            msg['To'] = ','.join(self.toaddrs)
            msg['Subject'] = self.getSubject(record)
            msg['Date'] = email.utils.localtime()
            msg.set_content(self.format(record))
            if self.username:
                if self.secure is not None:
                    smtp.ehlo()
                    smtp.starttls(*self.secure)
                    smtp.ehlo()
                smtp.login(self.username, self.password)
            smtp.send_message(msg)
            smtp.quit()
            # noinspection PyPep8
            very_nb_print(
                f'發送郵件給 {self.toaddrs} 成功,'
                f'用時{round(time.time() - t_start, 2)} ,發送的內容是--> {record.msg}                    \033[0;35m!!!請去郵箱檢查,可能在垃圾郵件中\033[0m')
        except Exception as e:
            # self.handleError(record)
            very_nb_print(
                f'[log_manager.py]   {time.strftime("%H:%M:%S", time.localtime())}  \033[0;31m !!!!!! 郵件發送失敗,原因是: {e} \033[0m') 
開發者ID:ydf0509,項目名稱:distributed_framework,代碼行數:36,代碼來源:log_manager000.py

示例7: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        """
        try:
            import smtplib
            from email.message import EmailMessage
            import email.utils

            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port, timeout=self.timeout)
            msg = EmailMessage()
            msg['From'] = self.fromaddr
            msg['To'] = ','.join(self.toaddrs)
            msg['Subject'] = self.getSubject(record)
            msg['Date'] = email.utils.localtime()
            msg.set_content(self.format(record))
            if self.username:
                if self.secure is not None:
                    smtp.ehlo()
                    smtp.starttls(*self.secure)
                    smtp.ehlo()
                smtp.login(self.username, self.password)
            smtp.send_message(msg)
            smtp.quit()
        except Exception:
            self.handleError(record) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:33,代碼來源:handlers.py

示例8: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        It would be really nice if I could add authorization to this class
        without having to resort to cut and paste inheritance but, no.
        """
        try:
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port)
            smtp.login(self.username, self.password)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                self.fromaddr,
                ','.join(self.toaddrs),
                self.getSubject(record),
                email.utils.formatdate(), msg)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record) 
開發者ID:VirtueSecurity,項目名稱:aws-extender,代碼行數:28,代碼來源:utils.py

示例9: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.
 
        Format the record and send it to the specified addressees.
        """

        try:
            try:
                from email.utils import formatdate
            except ImportError:
                formatdate = self.date_time
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                            self.fromaddr,
                            string.join(self.toaddrs, ","),
                            self.getSubject(record),
                            formatdate(), msg)
            smtp.ehlo()
            if smtp.has_extn('STARTTLS'):
                smtp.starttls()
            if self.username:
                smtp.login(self.username, self.password)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record)

# Test mySMTPHandler 
開發者ID:wfrog,項目名稱:wfrog,代碼行數:37,代碼來源:maillog.py

示例10: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """Emit a record.
        Format the record and send it to the specified addressees.
        """
        try:
            import smtplib

            try:
                from email.utils import formatdate
            except ImportError:
                formatdate = self.date_time

            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT

            smtp = smtplib.SMTP(self.mailhost, port)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                self.fromaddr,
                ",".join(self.toaddrs),
                self.getSubject(record),
                formatdate(),
                msg,
            )

            if self.username:
                smtp.ehlo()  # For 'tls', add this line
                smtp.starttls()  # For 'tls', add this line
                smtp.ehlo()  # For 'tls', add this line
                smtp.login(self.username, self.password)

            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()

        except (KeyboardInterrupt, SystemExit):
            raise

        except:
            self.handleError(record) 
開發者ID:Clinical-Genomics,項目名稱:scout,代碼行數:42,代碼來源:handlers.py

示例11: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        """
        try:
            import smtplib
            try:
                from email.Utils import formatdate
            except:
                formatdate = self.date_time
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                            self.fromaddr,
                            string.join(self.toaddrs, ","),
                            self.getSubject(record),
                            formatdate(), msg)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:30,代碼來源:handlers.py

示例12: emit

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTP_PORT [as 別名]
def emit(self, record):
        """
        Emit a record.

        Format the record and send it to the specified addressees.
        It would be really nice if I could add authorization to this class
        without having to resort to cut and paste inheritance but, no.
        """
        try:
            port = self.mailport
            if not port:
                port = smtplib.SMTP_PORT
            smtp = smtplib.SMTP(self.mailhost, port)
            smtp.login(self.username, self.password)
            msg = self.format(record)
            msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                            self.fromaddr,
                            ','.join(self.toaddrs),
                            self.getSubject(record),
                            formatdate(), msg)
            smtp.sendmail(self.fromaddr, self.toaddrs, msg)
            smtp.quit()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record) 
開發者ID:canvasnetworks,項目名稱:canvas,代碼行數:28,代碼來源:utils.py


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