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


Python smtplib.SMTPNotSupportedError方法代碼示例

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


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

示例1: test_smtputf8_NotSupportedError_if_no_server_support

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def test_smtputf8_NotSupportedError_if_no_server_support(self):
        smtp = smtplib.SMTP(
            HOST, self.port, local_hostname='localhost', timeout=3)
        self.addCleanup(smtp.close)
        smtp.ehlo()
        self.assertTrue(smtp.does_esmtp)
        self.assertFalse(smtp.has_extn('smtputf8'))
        self.assertRaises(
            smtplib.SMTPNotSupportedError,
            smtp.sendmail,
            'John', 'Sally', '', mail_options=['BODY=8BITMIME', 'SMTPUTF8'])
        self.assertRaises(
            smtplib.SMTPNotSupportedError,
            smtp.mail, 'John', options=['BODY=8BITMIME', 'SMTPUTF8']) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:16,代碼來源:test_smtplib.py

示例2: test_send_message_error_on_non_ascii_addrs_if_no_smtputf8

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
        msg = EmailMessage()
        msg['From'] = "Páolo <főo@bar.com>"
        msg['To'] = 'Dinsdale'
        msg['Subject'] = 'Nudge nudge, wink, wink \u1F609'
        smtp = smtplib.SMTP(
            HOST, self.port, local_hostname='localhost', timeout=3)
        self.addCleanup(smtp.close)
        self.assertRaises(smtplib.SMTPNotSupportedError,
                          smtp.send_message(msg)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:test_smtplib.py

示例3: login

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def login(self, username, password):
        try:
            return self.server.login(username, password)
        except smtplib.SMTPAuthenticationError:
            logger.error('The server did not accept the username/password combination.')
            return False
        except smtplib.SMTPNotSupportedError:
            logger.error('The AUTH command is not supported by the server.')
            exit(1)
        except smtplib.SMTPException:
            logger.error('Encountered an error during authentication.')
            exit(1) 
開發者ID:mikechabot,項目名稱:smtp-email-spoofer-py,代碼行數:14,代碼來源:smtpconnection.py

示例4: test_send_message_error_on_non_ascii_addrs_if_no_smtputf8

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
        # This test is located here and not in the SMTPUTF8SimTests
        # class because it needs a "regular" SMTP server to work
        msg = EmailMessage()
        msg['From'] = "Páolo <főo@bar.com>"
        msg['To'] = 'Dinsdale'
        msg['Subject'] = 'Nudge nudge, wink, wink \u1F609'
        smtp = smtplib.SMTP(
            HOST, self.port, local_hostname='localhost', timeout=3)
        self.addCleanup(smtp.close)
        with self.assertRaises(smtplib.SMTPNotSupportedError):
            smtp.send_message(msg) 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:14,代碼來源:test_smtplib.py

示例5: deliver_testcase

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def deliver_testcase(self, testcase, recipient):
        super().deliver_testcase(testcase, recipient)
        print("Sending test case {} from test '{}' to {}".format(self.testcase_index, self.testcases.name, recipient))
        self.allow_delay_increase()
        try:
            try:
                if testcase.delivery_sender:
                    sender = self.sender
                else:
                    sender = None
            except AttributeError:
                sender = None

            try:
                if testcase.delivery_recipient:
                    recipient = recipient
                else:
                    recipient = None
            except AttributeError:
                recipient = None

            result = self.smtp.send_message(testcase, sender, recipient)
            if result:
                for failed_recipient, (code, message) in result.items():
                    print("! Sending to recipient {} failed with error code {}: {}".format(failed_recipient, code, message))
                    self.logger.log(self.testcases.identifier, self.testcase_index, self.recipient, False, code, message)
                    if code in self.delay_increasing_status:
                        self.increase_delay()
            else:
                self.logger.log(self.testcases.identifier, self.testcase_index, self.recipient)
        except smtplib.SMTPRecipientsRefused as e:
            print("! Reciepent refused")
            for failed_recipient, (code, message) in e.recipients.items():
                print("! Sending to recipient {} failed with error code {}: {}".format(failed_recipient, code, str(message, "iso-8859-1")))
                self.logger.log(self.testcases.identifier, self.testcase_index, failed_recipient, False, code, str(message, "iso-8859-1"))
                if code in self.delay_increasing_status:
                    self.increase_delay()
        except smtplib.SMTPHeloError as e:
            print("! SMTP error while HELO: " + str(e))
            if e.smtp_code in self.delay_increasing_status:
                self.increase_delay()
        except smtplib.SMTPSenderRefused as e:
            print("! SMTP server rejected sender address: " + str(e))
            self.logger.log(self.testcases.identifier, self.testcase_index, self.recipient, False, e.smtp_code, e.smtp_error)
            if e.smtp_code in self.delay_increasing_status:
                self.increase_delay()
        except smtplib.SMTPDataError as e:
            print("! Unexpected SMTP error: " + str(e))
            self.logger.log(self.testcases.identifier, self.testcase_index, self.recipient, False, e.smtp_code, e.smtp_error)
            if e.smtp_code in self.delay_increasing_status:
                self.increase_delay()
        except smtplib.SMTPNotSupportedError as e:
            print("! SMTP server doesn't supports: " + str(e))
            self.logger.log(self.testcases.identifier, self.testcase_index, self.recipient, False, -1, str(e))
        except smtplib.SMTPServerDisconnected as e:
            self.logger.log(self.testcases.identifier, self.testcase_index, self.recipient, False, -2, str(e))
            print("! SMTP server disconnected unexpected - reconnecting: " + str(e))
            self.smtp = smtplib.SMTP(self.target) 
開發者ID:TKCERT,項目名稱:mail-security-tester,代碼行數:60,代碼來源:delivery.py

示例6: __init__

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def __init__(self,thread,starttime,opentrackurl,attach, sender , subject , message , *sendto ,**kwargs):


        al = Queue()

        smtp = kwargs['smtpt']
        mailhost = kwargs['mailhost']
        passwd = kwargs['passwd']
        port = kwargs['port']

        thr = int(thread)

        null = ""


        try:
            mail = smtplib.SMTP(smtp, port)
            mail.starttls()
            mail.login("{}".format(mailhost), '{}'.format(passwd))
            mail.quit()


            for i in range(thr):
                self.t = Thread(target=self.skeleton, args=(starttime,opentrackurl,attach,sender,message,subject, mailhost, passwd, smtp, int(port), al))
                self.t.daemon = True
                self.t.start()


            for mass in sendto:
                al.put(mass)

            al.join()

            os.startfile(os.getcwd() + '\\sleuth\\mailOpenList\\' + starttime + '.txt')

        except smtplib.SMTPAuthenticationError:
            print("Authentication Error", "Wrong Username or Password !", "Info")
            sys.stderr.flush()


        except smtplib.SMTPConnectError:
            print("Connection Error", "SMTP Server Down !", "Info")
            sys.stderr.flush()

        except smtplib.SMTPNotSupportedError:
            print("Support Error", "SMTP Not Supported !", "Info")
            sys.stderr.flush()

        except Exception as f:

            t, o, tb = sys.exc_info()
            print(f, tb.tb_lineno)
            sys.stderr.flush()

        #SendMail.skeleton(null,msg,mailhost,passwd,smtp,int(port),*sendto) 
開發者ID:azizaltuntas,項目名稱:Camelishing,代碼行數:57,代碼來源:smtp.py

示例7: send_alert

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def send_alert(self, alert_subscription):
		user = alert_subscription.user
		if not user.email_address:
			self.logger.debug("user {0} has no email address specified, skipping SMTP alert".format(user.name))
			return False

		msg = self.create_message(alert_subscription)
		if not msg:
			return False

		if self.config['smtp_ssl']:
			SmtpClass = smtplib.SMTP_SSL
		else:
			SmtpClass = smtplib.SMTP
		try:
			server = SmtpClass(self.config['smtp_server'], self.config['smtp_port'], timeout=15)
			server.ehlo()
		except smtplib.SMTPException:
			self.logger.warning('received an SMTPException while connecting to the SMTP server', exc_info=True)
			return False
		except socket.error:
			self.logger.warning('received a socket.error while connecting to the SMTP server')
			return False

		if not self.config['smtp_ssl'] and 'starttls' in server.esmtp_features:
			self.logger.debug('target SMTP server supports the STARTTLS extension')
			try:
				server.starttls()
				server.ehlo()
			except smtplib.SMTPException:
				self.logger.warning('received an SMTPException wile negotiating STARTTLS with SMTP server', exc_info=True)
				return False

		if self.config['smtp_username']:
			try:
				server.login(self.config['smtp_username'], self.config['smtp_password'])
			except smtplib.SMTPNotSupportedError:
				self.logger.debug('SMTP server does not support authentication')
			except smtplib.SMTPException as error:
				self.logger.warning("received an {0} while authenticating to the SMTP server".format(error.__class__.__name__))
				server.quit()
				return False

		mail_options = ['SMTPUTF8'] if server.has_extn('SMTPUTF8') else []
		try:
			server.sendmail(self.config['smtp_email'], alert_subscription.user.email_address, msg, mail_options)
		except smtplib.SMTPException as error:
			self.logger.warning("received error {0} while sending mail".format(error.__class__.__name__))
			return False
		finally:
			server.quit()
		self.logger.debug("successfully sent an email campaign alert to user: {0}".format(user.name))
		return True 
開發者ID:rsmusllp,項目名稱:king-phisher-plugins,代碼行數:55,代碼來源:__init__.py

示例8: sendEmailNotification

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPNotSupportedError [as 別名]
def sendEmailNotification(recipient, alert_name, content):

    sender = config_loader.get_config_str("Notifications", "sender")
    sender_user = config_loader.get_config_str("Notifications", "sender_user")
    sender_host = config_loader.get_config_str("Notifications", "sender_host")
    sender_port = config_loader.get_config_int("Notifications", "sender_port")
    sender_pw = config_loader.get_config_str("Notifications", "sender_pw")
    if sender_pw == 'None':
        sender_pw = None

    # raise an exception if any of these is None
    if (sender is None or
        sender_host is None or
        sender_port is None
        ):
        raise Exception('SMTP configuration (host, port, sender) is missing or incomplete!')

    try:
        if sender_pw is not None:
            try:
                smtp_server = smtplib.SMTP(sender_host, sender_port)
                smtp_server.starttls()
            except smtplib.SMTPNotSupportedError:
                print("The server does not support the STARTTLS extension.")
                smtp_server = smtplib.SMTP_SSL(sender_host, sender_port)

            smtp_server.ehlo()
            if sender_user is not None:
                smtp_server.login(sender_user, sender_pw)
            else:
                smtp_server.login(sender, sender_pw)
        else:
            smtp_server = smtplib.SMTP(sender_host, sender_port)

        mime_msg = MIMEMultipart()
        mime_msg['From'] = sender
        mime_msg['To'] = recipient
        mime_msg['Subject'] = "AIL Framework " + alert_name + " Alert"

        body = content
        mime_msg.attach(MIMEText(body, 'plain'))

        smtp_server.sendmail(sender, recipient, mime_msg.as_string())
        smtp_server.quit()
        print('Send notification ' + alert_name + ' to '+recipient)

    except Exception as err:
        traceback.print_tb(err.__traceback__)
        publisher.warning(err) 
開發者ID:CIRCL,項目名稱:AIL-framework,代碼行數:51,代碼來源:NotificationHelper.py


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