not to sure why this does this

server = smtplib.SMTP("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 10, in sendEmail
  File "/usr/lib/python2.5/", line 691, in sendmail
  File "/usr/lib/python2.5/", line 453, in rset
    return self.docmd("rset")
  File "/usr/lib/python2.5/", line 378, in docmd
    return self.getreply()
  File "/usr/lib/python2.5/", line 355, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed

Neither am I. Interacting with mail servers like yahoo and gmail is unfortuanaetly not as simple as: connect, login, email. See below for what I use, but you may need to experiment with yahoo. The basic flow is connect, say hi,encryt, say hi (all secret like), log in, mail stuff. Heh heh, the print statements might be more descriptive. See the SMTP class for more detail.

def email(usertuple,sendername,to,subject,msg):
    """Sends an email from a gmail account"""
    (login,pswd) = usertuple
    print 'Connecting...'
    mailServer = smtplib.SMTP("", 0)
    print 'Initiating relationship...'
    print 'Encrypting...'
    print 'Initiating encrypted relationship...'
    print 'Logging in...'
    print 'Mailing stuff...'
    message = """\
From: %s <%s>
MIME-Version: 1.0
Content-type: text/html
To: %s
Subject: %s

<font face = 'arial'>%s</font>
""" % (sendername, login,to, subject, msg)
    print sendername,to,message
    print 'Quitting...'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.