Socket Timeout and SMTP

Tim Williams listserver at tdw.net
Fri Jul 23 07:35:03 EDT 2004


(python newbie)

Is it possible to individually set the socket timeout of a connection
created by smtplib,  rather than use the socket.setdefaulttimeout() value
used by the rest of the prog/script?

eg:

import smtplib
import (other stuff)

socket.setdefaulttimeout(90)

class class1():
    ..
    ..
    smtp_client( some vals  )
    ..

class class2():
    ..
    ..
    smtp_client( some vals  )
    ..

def smtp_client(mx, from, to_list, msg):
    server = smtplib.SMTP(mx)
    (set socket timeout to XX)
    failed = mxserver.sendmail(from, to_list , msg)
    ...
    ...


def Start():
    .....


if __name__ == '__main__':
    Start()


TIA

Tim




More information about the Python-list mailing list