本文整理汇总了Python中slimta.relay.smtp.lmtpclient.LmtpRelayClient类的典型用法代码示例。如果您正苦于以下问题:Python LmtpRelayClient类的具体用法?Python LmtpRelayClient怎么用?Python LmtpRelayClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LmtpRelayClient类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_disconnect_failure
def test_disconnect_failure(self):
self.sock.sendall(b'QUIT\r\n')
self.sock.recv(IsA(int)).AndRaise(socket_error(None, None))
self.sock.close()
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._disconnect()
示例2: test_disconnect
def test_disconnect(self):
self.sock.sendall(b'QUIT\r\n')
self.sock.recv(IsA(int)).AndReturn(b'221 Goodbye\r\n')
self.sock.close()
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._disconnect()
示例3: test_lhlo
def test_lhlo(self):
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250-Hello\r\n250 TEST\r\n')
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'420 Goodbye\r\n')
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._ehlo()
with self.assertRaises(TransientRelayError):
client._ehlo()
示例4: test_deliver_conversion_failure
def test_deliver_conversion_failure(self):
result = self.mox.CreateMockAnything()
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test \x81\r\n')
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250-Hello\r\n250 PIPELINING\r\n')
self.sock.sendall(b'RSET\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
result.set_exception(IsA(PermanentRelayError))
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._ehlo()
client._deliver(result, env)
示例5: test_deliver_badpipeline
def test_deliver_badpipeline(self):
result = self.mox.CreateMockAnything()
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250-Hello\r\n250 PIPELINING\r\n')
self.sock.sendall(b'MAIL FROM:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\n')
self.sock.recv(IsA(int)).AndReturn(b'550 Not ok\r\n250 Ok\r\n354 Go ahead\r\n')
result.set_exception(IsA(PermanentRelayError))
self.sock.sendall(b'.\r\nRSET\r\n')
self.sock.recv(IsA(int)).AndReturn(b'550 Yikes\r\n250 Ok\r\n')
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._ehlo()
client._deliver(result, env)
示例6: test_deliver_conversion
def test_deliver_conversion(self):
result = self.mox.CreateMock(AsyncResult)
env = Envelope('[email protected]', ['[email protected]'])
env.parse('From: [email protected]\r\n\r\ntest test \x81\r\n')
self.sock.sendall('LHLO test\r\n')
self.sock.recv(IsA(int)).AndReturn('250-Hello\r\n250 PIPELINING\r\n')
self.sock.sendall('MAIL FROM:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n250 Ok\r\n354 Go ahead\r\n')
self.sock.sendall('From: [email protected]\r\nContent-Transfer-Encoding: base64\r\n\r\ndGVzdCB0ZXN0IIENCg==\n\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n')
result.set([None])
self.mox.ReplayAll()
client = LmtpRelayClient(None, self.queue, socket_creator=self._socket_creator, ehlo_as='test', binary_encoder=encode_base64)
client._connect()
client._ehlo()
client._deliver(result, env)
示例7: test_deliver_rset_exception
def test_deliver_rset_exception(self):
result = self.mox.CreateMockAnything()
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250-Hello\r\n250 PIPELINING\r\n')
self.sock.sendall(b'MAIL FROM:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n250 Ok\r\n450 No!\r\n')
result.set_exception(IsA(TransientRelayError))
self.sock.sendall(b'RSET\r\n')
self.sock.recv(IsA(int)).AndRaise(ConnectionLost)
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._ehlo()
with self.assertRaises(ConnectionLost):
client._deliver(result, env)
示例8: test_deliver_multircpt
def test_deliver_multircpt(self):
result = self.mox.CreateMock(AsyncResult)
env = Envelope('[email protected]', ['[email protected]', '[email protected]', '[email protected]'])
env.parse('From: [email protected]\r\n\r\ntest test\r\n')
self.sock.sendall('LHLO test\r\n')
self.sock.recv(IsA(int)).AndReturn('250-Hello\r\n250 PIPELINING\r\n')
self.sock.sendall('MAIL FROM:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n250 Ok\r\n550 Nope\r\n250 Ok\r\n354 Go ahead\r\n')
self.sock.sendall('From: [email protected]\r\n\r\ntest test\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n450 Yikes\r\n')
result.set([None, IsA(PermanentRelayError), IsA(TransientRelayError)])
self.sock.sendall('RSET\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n')
self.mox.ReplayAll()
client = LmtpRelayClient(None, self.queue, socket_creator=self._socket_creator, ehlo_as='test')
client._connect()
client._ehlo()
client._deliver(result, env)
示例9: test_deliver_conversion
def test_deliver_conversion(self):
result = self.mox.CreateMockAnything()
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test \x81\r\n')
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250-Hello\r\n250 PIPELINING\r\n')
self.sock.sendall(b'MAIL FROM:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n250 Ok\r\n354 Go ahead\r\n')
if pycompat.PY3:
self.sock.sendall(b'From: [email protected]\r\nContent-Transfer-Encoding: base64\r\n\r\ndGVzdCB0ZXN0IIEK\r\n.\r\n')
else:
self.sock.sendall(b'From: [email protected]\r\nContent-Transfer-Encoding: base64\r\n\r\ndGVzdCB0ZXN0IIENCg==\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
result.set({'[email protected]': Reply('250', 'Ok')})
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there', binary_encoder=encode_base64)
client._connect()
client._ehlo()
client._deliver(result, env)
示例10: test_deliver
def test_deliver(self):
result = self.mox.CreateMockAnything()
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test \x81\r\n')
self.sock.sendall(b'LHLO there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250-Hello\r\n250 8BITMIME\r\n')
self.sock.sendall(b'MAIL FROM:<[email protected]>\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
self.sock.sendall(b'RCPT TO:<[email protected]>\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
self.sock.sendall(b'DATA\r\n')
self.sock.recv(IsA(int)).AndReturn(b'354 Go ahead\r\n')
self.sock.sendall(b'From: [email protected]\r\n\r\ntest test \x81\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
result.set({'[email protected]': Reply('250', 'Ok')})
self.mox.ReplayAll()
client = LmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator, ehlo_as='there')
client._connect()
client._ehlo()
client._deliver(result, env)
示例11: test_deliver
def test_deliver(self):
result = self.mox.CreateMock(AsyncResult)
env = Envelope('[email protected]', ['[email protected]'])
env.parse('From: [email protected]\r\n\r\ntest test \x81\r\n')
self.sock.sendall('LHLO test\r\n')
self.sock.recv(IsA(int)).AndReturn('250-Hello\r\n250 8BITMIME\r\n')
self.sock.sendall('MAIL FROM:<[email protected]>\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n')
self.sock.sendall('RCPT TO:<[email protected]>\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n')
self.sock.sendall('DATA\r\n')
self.sock.recv(IsA(int)).AndReturn('354 Go ahead\r\n')
self.sock.sendall('From: [email protected]\r\n\r\ntest test \x81\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn('250 Ok\r\n')
result.set([None])
self.mox.ReplayAll()
client = LmtpRelayClient(None, self.queue, socket_creator=self._socket_creator, ehlo_as='test')
client._connect()
client._ehlo()
client._deliver(result, env)