当前位置: 首页>>代码示例>>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;未经允许,请勿转载。