question about smtplib

Steve Holden steve at holdenweb.com
Mon Oct 3 23:30:14 CEST 2005


nephish at xit.net wrote:
> Hey there,
> 
> i am using the smtplib module in python 2.3
> 
> my question is, this works:
> 
> server = smtplib.SMTP(localhost)
> 
> then server.sendmail(to address, from address, message)
> 
> 
> what i want to know is, how does the connection work?
> 
> when i do server.sendmail, does it connect then ? or did it connect
> when
> i made the object ?
> 
> the reason i need to know is i need to send several emails out at once
> and would be best to only connect once, i think.
> 
> i know that i can call server.close(), i just dont know when it was
> opened.
> thanks
> 
If you provide the host name the server is connected immediately. You 
can use that connection to send several emails, terminating the 
connection when you call the object's quit() method.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list