not to sure why this does this

server = smtplib.SMTP("smtp.mail.yahoo.com")
server.connect("www.mail.yahoo.com")
sendEmail("FlexPt1.txt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 10, in sendEmail
  File "/usr/lib/python2.5/smtplib.py", line 691, in sendmail
    self.rset()
  File "/usr/lib/python2.5/smtplib.py", line 453, in rset
    return self.docmd("rset")
  File "/usr/lib/python2.5/smtplib.py", line 378, in docmd
    return self.getreply()
  File "/usr/lib/python2.5/smtplib.py", 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("smtp.gmail.com", 0)
    print 'Initiating relationship...'
    mailServer.ehlo()
    print 'Encrypting...'
    mailServer.starttls()
    print 'Initiating encrypted relationship...'
    mailServer.ehlo()
    print 'Logging in...'
    mailServer.login(login,pswd)
    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
    mailServer.sendmail(sendername,to,message)
    print 'Quitting...'
    mailServer.close()
Be a part of the DaniWeb community

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