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


Python Client.send_empty_data方法代码示例

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


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

示例1: test_send_empty_data

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

示例2: test_send_empty_data

# 需要导入模块: from slimta.smtp.client import Client [as 别名]
# 或者: from slimta.smtp.client.Client import send_empty_data [as 别名]
 def test_send_empty_data(self):
     self.sock.sendall('.\r\n')
     self.sock.recv(IsA(int)).AndReturn('250 2.0.0 Done\r\n')
     self.mox.ReplayAll()
     client = Client(self.sock)
     reply = client.send_empty_data()
     assert_equal('250', reply.code)
     assert_equal('2.0.0 Done', reply.message)
     assert_equal('[SEND_DATA]', reply.command)
开发者ID:drewlander,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_smtp_client.py

示例3: SmtpRelayClient

# 需要导入模块: from slimta.smtp.client import Client [as 别名]
# 或者: from slimta.smtp.client.Client import send_empty_data [as 别名]

#.........这里部分代码省略.........
        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

    def _send_envelope(self, result, envelope):
        data = None
        try:
            mailfrom = self._mailfrom(envelope.sender)
            rcpttos = [self._rcptto(rcpt) for rcpt in envelope.recipients]
            with Timeout(self.command_timeout):
                data = self.client.data()
            self._check_replies(mailfrom, rcpttos, data)
        except SmtpRelayError as e:
            if data and not data.is_error():
                with Timeout(self.data_timeout):
                    self.client.send_empty_data()
            self._rset()
            result.set_exception(e)
            return False
        try:
            self._send_message_data(envelope)
        except SmtpRelayError as e:
            self._rset()
            result.set_exception(e)
            return False
        return True

    def _check_server_timeout(self):
        if self.client.has_reply_waiting():
            with Timeout(self.command_timeout):
                timeout = self.client.get_reply()
            return True

    def _disconnect(self):
        try:
            with Timeout(self.command_timeout):
                self.client.quit()
        except Exception:
            pass
        finally:
            if self.client:
                self.client.io.close()

    def _run(self):
        try:
            self._connect()
            self._handshake()
            while True:
                self.idle = True
                n, result, envelope = self.queue.get(timeout=self.idle_timeout)
                self.idle = False
                if self._check_server_timeout():
                    self.queue.put((0, result, envelope))
                    break
                if self._send_envelope(result, envelope):
                    result.set(True)
                if self.idle_timeout is None:
                    break
        except (Empty, Timeout):
            pass
        finally:
            self._disconnect()
开发者ID:akatrevorjay,项目名称:python-slimta,代码行数:104,代码来源:client.py


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