sending emails using python

sridhar ramasridhar.kasturi at
Thu Sep 7 07:37:29 CEST 2006

iam having user account on an exchangeserver.
with that can i send an email using python?

if iam using the following code iam getting error

fromAddress = 'sridhar_kasturi at'
toAddress = 'sridhar_kasturi at'
msg = "Subject: Hello\n\nThis is the body of the message."
import smtplib
server = smtplib.SMTP("hstmsg002",25)
server.sendmail(fromAddress, toAddress, msg)


Traceback (most recent call last):
line 5, in ?
    server = smtplib.SMTP("hstmsg002",25)
  File "C:\Python24\lib\", line 244, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python24\lib\", line 307, in connect
    (code, msg) = self.getreply()
  File "C:\Python24\lib\", line 351, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
SMTPServerDisconnected: Connection unexpectedly closed

More information about the Python-list mailing list