本文整理汇总了Python中slimta.relay.smtp.mx.MxSmtpRelay类的典型用法代码示例。如果您正苦于以下问题:Python MxSmtpRelay类的具体用法?Python MxSmtpRelay怎么用?Python MxSmtpRelay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MxSmtpRelay类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_choose_mx
def test_choose_mx(self):
records = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]
mx = MxSmtpRelay()
self.assertEqual(1, mx.choose_mx(records, 0))
self.assertEqual(5, mx.choose_mx(records, 4))
self.assertEqual(1, mx.choose_mx(records, 5))
self.assertEqual(3, mx.choose_mx(records, 7))
self.assertEqual(2, mx.choose_mx(records, 1821))
示例2: test_attempt_no_answer
def test_attempt_no_answer(self):
env = Envelope("[email protected]", ["[email protected]"])
mx = MxSmtpRelay()
self.mox.StubOutWithMock(mx, "new_static_relay")
self.mox.StubOutWithMock(dns_resolver, "query")
dns_resolver.query("example.com", "MX").AndRaise(DNSTimeout)
self.mox.ReplayAll()
with assert_raises(TransientRelayError):
mx.attempt(env, 0)
示例3: test_attempt_no_answer
def test_attempt_no_answer(self):
env = Envelope('[email protected]', ['[email protected]'])
mx = MxSmtpRelay()
self.mox.StubOutWithMock(mx, 'new_static_relay')
self.mox.StubOutWithMock(dns_resolver, 'query')
dns_resolver.query('example.com', 'MX').AndRaise(DNSTimeout)
self.mox.ReplayAll()
with self.assertRaises(TransientRelayError):
mx.attempt(env, 0)
示例4: test_attempt_no_records
def test_attempt_no_records(self):
env = Envelope('[email protected]', ['[email protected]'])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, 'new_static_relay')
self.mox.StubOutWithMock(dns.resolver, 'query')
dns.resolver.query('example.com', 'MX').AndRaise(dns.resolver.NXDOMAIN)
dns.resolver.query('example.com', 'A').AndRaise(dns.resolver.NXDOMAIN)
self.mox.ReplayAll()
with self.assertRaises(PermanentRelayError):
mx.attempt(env, 0)
示例5: test_attempt_no_records
def test_attempt_no_records(self):
env = Envelope("[email protected]", ["[email protected]"])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, "new_static_relay")
self.mox.StubOutWithMock(dns_resolver, "query")
dns_resolver.query("example.com", "MX").AndRaise(dns.resolver.NXDOMAIN)
dns_resolver.query("example.com", "A").AndRaise(dns.resolver.NXDOMAIN)
self.mox.ReplayAll()
with assert_raises(PermanentRelayError):
mx.attempt(env, 0)
示例6: test_attempt_no_mx
def test_attempt_no_mx(self):
env = Envelope('[email protected]', ['[email protected]'])
a_ret = FakeAAnswer(False, [('1.2.3.4', )])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, 'new_static_relay')
self.mox.StubOutWithMock(dns.resolver, 'query')
dns.resolver.query('example.com', 'MX').AndRaise(dns.resolver.NXDOMAIN)
dns.resolver.query('example.com', 'A').AndReturn(a_ret)
mx.new_static_relay('1.2.3.4', 25).AndReturn(static)
static.attempt(env, 0)
self.mox.ReplayAll()
mx.attempt(env, 0)
示例7: test_attempt_no_mx
def test_attempt_no_mx(self):
env = Envelope("[email protected]", ["[email protected]"])
a_ret = FakeAAnswer(False, [("1.2.3.4",)])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, "new_static_relay")
self.mox.StubOutWithMock(dns_resolver, "query")
dns_resolver.query("example.com", "MX").AndRaise(dns.resolver.NXDOMAIN)
dns_resolver.query("example.com", "A").AndReturn(a_ret)
mx.new_static_relay("1.2.3.4", 25).AndReturn(static)
static.attempt(env, 0)
self.mox.ReplayAll()
mx.attempt(env, 0)
示例8: test_attempt_force_mx
def test_attempt_force_mx(self):
env = Envelope('[email protected]', ['[email protected]'])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, 'new_static_relay')
mx.new_static_relay('mail.example.com', 25).AndReturn(static)
static.attempt(env, 0)
static.attempt(env, 1)
self.mox.ReplayAll()
mx.force_mx('example.com', 'mail.example.com')
mx.attempt(env, 0)
mx.attempt(env, 1)
示例9: test_attempt
def test_attempt(self):
env = Envelope("[email protected]", ["[email protected]"])
mx_ret = FakeMxAnswer(False, [(5, "mx1.example.com"), (10, "mx2.example.com")])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, "new_static_relay")
self.mox.StubOutWithMock(dns_resolver, "query")
dns_resolver.query("example.com", "MX").AndReturn(mx_ret)
mx.new_static_relay("mx1.example.com", 25).AndReturn(static)
static.attempt(env, 0)
mx.new_static_relay("mx2.example.com", 25).AndReturn(static)
static.attempt(env, 1)
self.mox.ReplayAll()
mx.attempt(env, 0)
mx.attempt(env, 1)
示例10: test_attempt
def test_attempt(self):
env = Envelope('[email protected]', ['[email protected]'])
mx_ret = FakeMxAnswer(False, [(5, 'mx1.example.com'),
(10, 'mx2.example.com')])
mx = MxSmtpRelay()
static = self.mox.CreateMock(StaticSmtpRelay)
self.mox.StubOutWithMock(mx, 'new_static_relay')
self.mox.StubOutWithMock(dns.resolver, 'query')
dns.resolver.query('example.com', 'MX').AndReturn(mx_ret)
mx.new_static_relay('mx1.example.com', 25).AndReturn(static)
static.attempt(env, 0)
mx.new_static_relay('mx2.example.com', 25).AndReturn(static)
static.attempt(env, 1)
self.mox.ReplayAll()
mx.attempt(env, 0)
mx.attempt(env, 1)
示例11: test_get_rcpt_domain
def test_get_rcpt_domain(self):
env = Envelope('[email protected]', ['[email protected]'])
mx = MxSmtpRelay()
self.assertEqual('example.com', mx._get_rcpt_domain(env))
示例12: test_get_rcpt_domain
def test_get_rcpt_domain(self):
env = Envelope("[email protected]", ["[email protected]"])
mx = MxSmtpRelay()
assert_equal("example.com", mx._get_rcpt_domain(env))