• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python server.Server类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中slimta.smtp.server.Server的典型用法代码示例。如果您正苦于以下问题:Python Server类的具体用法?Python Server怎么用?Python Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Server类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_recv_command

 def test_recv_command(self):
     self.sock.recv(IsA(int)).AndReturn(b'cmd ARG\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     cmd, arg = s._recv_command()
     self.assertEqual(b'CMD', cmd)
     self.assertEqual(b'ARG', arg)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_smtp_server.py


示例2: test_gather_params

 def test_gather_params(self):
     s = Server(None, None)
     self.assertEqual({b'ONE': b'1'}, s._gather_params(b' ONE=1'))
     self.assertEqual({b'TWO': True}, s._gather_params(b'TWO'))
     self.assertEqual({b'THREE': b'foo', b'FOUR': b'bar'},
                      s._gather_params(b' THREE=foo FOUR=bar'))
     self.assertEqual({b'FIVE': True}, s._gather_params(b'five'))
开发者ID:dldorsey,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_smtp_server.py


示例3: test_banner_quit

 def test_banner_quit(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_smtp_server.py


示例4: test_tls_immediately

 def test_tls_immediately(self):
     self.context.wrap_socket(self.sock, server_side=True).AndReturn(self.sock)
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None, context=self.context, tls_immediately=True)
     s.handle()
开发者ID:slimta,项目名称:python-slimta,代码行数:8,代码来源:test_slimta_smtp_server.py


示例5: test_noop

 def test_noop(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'NOOP\r\n')
     self.sock.sendall(b'250 2.0.0 Ok\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_smtp_server.py


示例6: test_quit_bad

 def test_quit_bad(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT arg\r\n')
     self.sock.sendall(b'501 5.5.4 Syntax error in parameters or arguments\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_smtp_server.py


示例7: test_tls_immediately_sslerror

 def test_tls_immediately_sslerror(self):
     sock = self.mox.CreateMockAnything()
     sock.fileno = lambda: -1
     sock.tls_wrapper(sock, self.tls_args).AndRaise(SSLError())
     sock.sendall(b'421 4.7.0 TLS negotiation failed\r\n')
     self.mox.ReplayAll()
     s = Server(sock, None, tls=self.tls_args, tls_immediately=True,
                tls_wrapper=sock.tls_wrapper)
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_smtp_server.py


示例8: test_helo

 def test_helo(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'HELO there\r\n')
     self.sock.sendall(b'250 Hello there\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
     self.assertEqual('there', s.ehlo_as)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:10,代码来源:test_slimta_smtp_server.py


示例9: test_helo_empty

 def test_helo_empty(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'HELO\r\n')
     self.sock.sendall(b'501 5.5.4 Syntax error in parameters or arguments\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
     self.assertEqual(None, s.ehlo_as)
开发者ID:slimta,项目名称:python-slimta,代码行数:10,代码来源:test_slimta_smtp_server.py


示例10: test_unhandled_error

 def test_unhandled_error(self):
     class TestHandler(object):
         def BANNER_(self, reply):
             raise Exception('test')
     self.sock.sendall(b'421 4.3.0 Unhandled system error\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, TestHandler())
     with self.assertRaises(Exception) as cm:
         s.handle()
     self.assertEqual(('test', ), cm.exception.args)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:10,代码来源:test_slimta_smtp_server.py


示例11: test_get_message_data

 def test_get_message_data(self):
     expected_reply = b'250 2.6.0 Message accepted for delivery\r\n'
     self.sock.recv(IsA(int)).AndReturn(b'one\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'.\r\n')
     self.sock.sendall(expected_reply)
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s._get_message_data()
     self.assertFalse(s.have_mailfrom)
     self.assertFalse(s.have_rcptto)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:10,代码来源:test_slimta_smtp_server.py


示例12: test_data_connectionlost

 def test_data_connectionlost(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'DATA\r\n')
     self.sock.sendall(b'354 Start mail input; end with <CRLF>.<CRLF>\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.ehlo_as = b'test'
     s.have_mailfrom = True
     s.have_rcptto = True
     self.assertRaises(ConnectionLost, s.handle)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_smtp_server.py


示例13: test_banner_command

 def test_banner_command(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'BANNER\r\n')
     self.sock.sendall(b'500 5.5.2 Syntax error, command unrecognized\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'BANNER_\r\n')
     self.sock.sendall(b'500 5.5.2 Syntax error, command unrecognized\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_smtp_server.py


示例14: test_tls_immediately

 def test_tls_immediately(self):
     sock = self.mox.CreateMockAnything()
     sock.fileno = lambda: -1
     sock.tls_wrapper(sock, self.tls_args).AndReturn(sock)
     sock.sendall(b'220 ESMTP server\r\n')
     sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(sock, None, tls=self.tls_args, tls_immediately=True,
                tls_wrapper=sock.tls_wrapper)
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_smtp_server.py


示例15: test_ehlo

 def test_ehlo(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'EHLO there\r\n')
     self.sock.sendall(b'250-Hello there\r\n250 TEST\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.extensions.reset()
     s.extensions.add('TEST')
     s.handle()
     self.assertEqual('there', s.ehlo_as)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:12,代码来源:test_slimta_smtp_server.py


示例16: test_mailfrom

 def test_mailfrom(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'HELO there\r\n')
     self.sock.sendall(b'250 Hello there\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'MAIL FROM:<test">"addr>\r\n')
     self.sock.sendall(b'250 2.1.0 Sender <test">"addr> Ok\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.handle()
     self.assertTrue(s.have_mailfrom)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:12,代码来源:test_slimta_smtp_server.py


示例17: test_data_bad

 def test_data_bad(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'DATA arg\r\n')
     self.sock.sendall(b'501 5.5.4 Syntax error in parameters or arguments\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'DATA\r\n')
     self.sock.sendall(b'503 5.5.1 Bad sequence of commands\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.ehlo_as = b'test'
     s.have_mailfrom = True
     s.handle()
开发者ID:dldorsey,项目名称:python-slimta,代码行数:13,代码来源:test_slimta_smtp_server.py


示例18: handle

 def handle(self, socket, address):
     try:
         handlers = SmtpSession(address, self.validator_class, self.handoff)
         smtp_server = Server(socket, handlers, self.auth_class,
                              self.tls, self.tls_immediately,
                              command_timeout=self.command_timeout,
                              data_timeout=self.data_timeout)
         if self.max_size:
             smtp_server.extensions.add('SIZE', self.max_size)
         smtp_server.handle()
     except ConnectionLost:
         pass
     finally:
         smtp_server.io.close()
开发者ID:rafaelnovello,项目名称:python-slimta,代码行数:14,代码来源:smtp.py


示例19: test_helo_empty_with_ehlo

 def test_helo_empty_with_ehlo(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'HELO\r\n')
     self.sock.sendall(b'501 5.5.4 Syntax error in parameters or arguments\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'EHLO there\r\n')
     self.sock.sendall(b'250-Hello there\r\n250 TEST\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.extensions.reset()
     s.extensions.add('TEST')
     s.handle()
     self.assertEqual('there', s.ehlo_as)
开发者ID:slimta,项目名称:python-slimta,代码行数:14,代码来源:test_slimta_smtp_server.py


示例20: test_rcptto

 def test_rcptto(self):
     self.sock.sendall(b'220 ESMTP server\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'RCPT TO:<test">"addr>\r\n')
     self.sock.sendall(b'250 2.1.5 Recipient <test">"addr> Ok\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'RCPT TO:<test2>\r\n')
     self.sock.sendall(b'250 2.1.5 Recipient <test2> Ok\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
     self.sock.sendall(b'221 2.0.0 Bye\r\n')
     self.mox.ReplayAll()
     s = Server(self.sock, None)
     s.ehlo_as = b'test'
     s.have_mailfrom = True
     s.handle()
     self.assertTrue(s.have_rcptto)
开发者ID:dldorsey,项目名称:python-slimta,代码行数:14,代码来源:test_slimta_smtp_server.py



注:本文中的slimta.smtp.server.Server类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python deque.BlockingDeque类代码示例发布时间:2022-05-27
下一篇:
Python reply.Reply类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap