views:

62

answers:

1

Hi there, recently i'm studing the smtplib smtp client library for python, but i could not find any reference to the PIPELINING protocol against smtp servers that support it. Is there something i'm missing? It's not yet implemented maybe? Any other implementations rather than smtplib with PIPELINING enabled?

Thanks

+2  A: 

Is there something i'm missing?

Quite possibly.

Simply put PIPELINING is sending SMTP commands without waiting for the responses. It doesn't tend to be implemented because the benefits are marginal and it increases the complexity of error states.

From your comment, it sounds as if you are worried that only one message will be sent through one connection. This is not PIPELINING.

smtplib supports using the same connection for multiple messages. You can just call sendmail multiple times. E.g.

s = smtplib.SMTP("localhost")
s.sendmail("[email protected]",["[email protected]"],message1)
s.sendmail("[email protected]",["[email protected]"],message2)

Final update

which is the max number of messages i can append "per-connection" ?

This varies between SMTP daemons. Exim seems to default to 1000.

do i have to do this synchronously or does smtplib eventually handle contemporary sendmail calls ?

The call to the sendmail method will block until complete, your calls will be sequential.

If you need to parallelize then you might need to look at threading, multiprocessing or perhaps twisted. There are many possible approaches.

The number of concurrent connections you are allowed may also be an SMTP daemon configuration item.

MattH
I didn't know that, thanks :)
Simone Margaritelli
You are very welcome!
MattH
Two last things, which is the max number of messages i can append "per-connection" ? And, do i have to do this synchronously or does smtplib eventually handle contemporary sendmail calls ?
Simone Margaritelli