def __init__(self): """Create a basic deliverer.""" username = (config.mta.smtp_user if config.mta.smtp_user else None) password = (config.mta.smtp_pass if config.mta.smtp_pass else None) self._connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), int(config.mta.max_sessions_per_connection), username, password)
def __init__(self): """Create a basic deliverer.""" self._connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), int(config.mta.max_sessions_per_connection), config.mta.smtp_user if config.mta.smtp_user else None, config.mta.smtp_pass if config.mta.smtp_pass else None, as_SecureMode(config.mta.smtp_secure_mode), as_boolean(config.mta.smtp_verify_cert), as_boolean(config.mta.smtp_verify_hostname), )
def test_authentication_good_path(self): # Logging in with the correct user name and password succeeds. connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), 0, 'testuser', 'testpass') connection.sendmail('*****@*****.**', ['*****@*****.**'], """\ From: [email protected] To: [email protected] Subject: aardvarks """) self.assertEqual(self.layer.smtpd.get_authentication_credentials(), 'AHRlc3R1c2VyAHRlc3RwYXNz')
def test_not_supported(self): connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), 0, secure_mode=SecureMode.STARTTLS, verify_cert=False ) msg_text = """\ From: [email protected] To: [email protected] Subject: aardvarks """ LogFileMark('mailman.smtp') with self.assertRaises(SMTPNotSupportedError): connection.sendmail( '*****@*****.**', ['*****@*****.**'], msg_text)
def test_authentication_error(self): # Logging in to the MTA with a bad user name and password produces a # 571 Bad Authentication error. with self.assertRaises(SMTPAuthenticationError) as cm: connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), 0, 'baduser', 'badpass') connection.sendmail('*****@*****.**', ['*****@*****.**'], """\ From: [email protected] To: [email protected] Subject: aardvarks """) self.assertEqual(cm.exception.smtp_code, 571) self.assertEqual(cm.exception.smtp_error, b'Bad authentication')
def setUp(self): self.connection = Connection(config.mta.smtp_host, int(config.mta.smtp_port), 0) self.msg_text = """\
def setUp(self): super().setUp() self.connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), 0, secure_mode=SecureMode.STARTTLS, verify_cert=False )
def test_exception_is_raised_from_connect(self, mocked_SMTP): connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), 0) with self.assertRaises(Exception): connection._connect() self.assertTrue(mocked_SMTP.called)
def setUp(self): super().setUp() self.connection = Connection( config.mta.smtp_host, int(config.mta.smtp_port), 0)