Hi Eli!
Here's an idea:
It seems class smtplib.SMTP sends the message with method 'send', that calls a
socket's 'sendall' (from Python 2.4's smtplib.py)
def send(self, str):
Send `str' to the server.
# .. skipping
self.sock.sendall(str)
# .. skipping
You could subclass smtplib.SMTP, and reimplement method 'send' using Socket.send
instead of Socket.sendall to send chunks, and do whatever you want then.
For example, you could call a callback with the bytes sent:
def send(self, str, chunk_size=512, callback=lambda bytes_sent: None):
Send `str' to the server.
# .. skipping
bytes_sent = 0
while bytes_sent len(str):
chunk = str[bytes_sent:bytes_sent+chunk_size]
bytes_sent += self.sock.send(chunk)
callback(bytes_sent)
# .. skipping
I haven't tested it, but it seems about right.
Ori.
Eli Golovinsky wrote:
I am sending large email messages (with MIME parts) using this recipe :
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473810
But I can't find any way to monitor the progress (i.e. how many bytes
have been delivered until now) of the sending.
Anybody has an idea how I can accomplish that?