当前位置: 首页>>代码示例>>Python>>正文


Python Client.rcptto方法代码示例

本文整理汇总了Python中slimta.smtp.client.Client.rcptto方法的典型用法代码示例。如果您正苦于以下问题:Python Client.rcptto方法的具体用法?Python Client.rcptto怎么用?Python Client.rcptto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在slimta.smtp.client.Client的用法示例。


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

示例1: test_rcptto

# 需要导入模块: from slimta.smtp.client import Client [as 别名]
# 或者: from slimta.smtp.client.Client import rcptto [as 别名]
 def test_rcptto(self):
     self.sock.sendall(b"RCPT TO:<test>\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250 2.0.0 Ok\r\n")
     self.mox.ReplayAll()
     client = Client(self.sock)
     reply = client.rcptto("test")
     self.assertEqual("250", reply.code)
     self.assertEqual("2.0.0 Ok", reply.message)
     self.assertEqual(b"RCPT", reply.command)
开发者ID:oasiswork,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_smtp_client.py

示例2: test_rcptto_pipelining

# 需要导入模块: from slimta.smtp.client import Client [as 别名]
# 或者: from slimta.smtp.client.Client import rcptto [as 别名]
 def test_rcptto_pipelining(self):
     self.sock.sendall(b"RCPT TO:<test>\r\n")
     self.sock.recv(IsA(int)).AndReturn(b"250 2.0.0 Ok\r\n")
     self.mox.ReplayAll()
     client = Client(self.sock)
     client.extensions.add("PIPELINING")
     reply = client.rcptto("test")
     self.assertEqual(None, reply.code)
     self.assertEqual(None, reply.message)
     self.assertEqual(b"RCPT", reply.command)
     client._flush_pipeline()
     self.assertEqual("250", reply.code)
     self.assertEqual("2.0.0 Ok", reply.message)
开发者ID:oasiswork,项目名称:python-slimta,代码行数:15,代码来源:test_slimta_smtp_client.py

示例3: SmtpRelayClient

# 需要导入模块: from slimta.smtp.client import Client [as 别名]
# 或者: from slimta.smtp.client.Client import rcptto [as 别名]
class SmtpRelayClient(Greenlet):

    def __init__(self, address, queue, socket_creator=None, ehlo_as=None,
                       tls=None, tls_immediately=False,
                       tls_required=False, tls_wrapper=None,
                       connect_timeout=None, command_timeout=None,
                       data_timeout=None, idle_timeout=None):
        super(SmtpRelayClient, self).__init__()
        self.address = address
        self.queue = queue
        self.idle = False
        if socket_creator:
            self._socket_creator = socket_creator
        self.socket = None
        self.client = None
        self.ehlo_as = ehlo_as or hostname
        self.tls = tls
        self.tls_immediately = tls_immediately
        self.tls_required = tls_required
        self.tls_wrapper = tls_wrapper
        self.connect_timeout = connect_timeout
        self.command_timeout = command_timeout
        self.data_timeout = data_timeout
        self.idle_timeout = idle_timeout

    def _socket_creator(self, address):
        socket = create_connection(address)
        log.connect(socket, address)
        return socket

    def _connect(self):
        with Timeout(self.connect_timeout):
            self.socket = self._socket_creator(self.address)
        self.client = Client(self.socket, self.tls_wrapper)

    def _banner(self):
        with Timeout(self.command_timeout):
            banner = self.client.get_banner()
        if banner.is_error():
            raise SmtpRelayError.factory(banner)

    def _ehlo(self):
        with Timeout(self.command_timeout):
            ehlo = self.client.ehlo(self.ehlo_as)
        if ehlo.is_error():
            raise SmtpRelayError.factory(ehlo)

    def _starttls(self):
        with Timeout(self.command_timeout):
            starttls = self.client.starttls(self.tls)
        if starttls.is_error() and self.tls_required:
            raise SmtpRelayError.factory(starttls)

    def _handshake(self):
        if self.tls and self.tls_immediately:
            self.client.encrypt(self.tls)
        self._banner()
        self._ehlo()
        if self.tls and not self.tls_immediately:
            self._starttls()
            self._ehlo()

    def _rset(self):
        with Timeout(self.command_timeout):
            rset = self.client.rset()

    def _mailfrom(self, sender):
        with Timeout(self.command_timeout):
            mailfrom = self.client.mailfrom(sender)
        if mailfrom and mailfrom.is_error():
            raise SmtpRelayError.factory(mailfrom)
        return mailfrom

    def _rcptto(self, rcpt):
        with Timeout(self.command_timeout):
            rcptto = self.client.rcptto(rcpt)
        if rcptto and rcptto.is_error():
            raise SmtpRelayError.factory(rcptto)
        return rcptto

    def _check_replies(self, mailfrom, rcpttos, data):
        if mailfrom.is_error():
            raise SmtpRelayError.factory(mailfrom)
        for rcptto in rcpttos:
            if not rcptto.is_error():
                break
        else:
            raise SmtpRelayError.factory(rcpttos[0])
        if data.is_error():
            raise SmtpRelayError.factory(data)

    def _send_message_data(self, envelope):
        header_data, message_data = envelope.flatten()
        with Timeout(self.data_timeout):
            send_data = self.client.send_data(header_data, message_data)
        self.client._flush_pipeline()
        if send_data.is_error():
            raise SmtpRelayError.factory(send_data)
        return send_data

#.........这里部分代码省略.........
开发者ID:akatrevorjay,项目名称:python-slimta,代码行数:103,代码来源:client.py


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