"smtplib.SMTPServerDisconnected: please run connect() first"

K

kj

I'm getting the error:

smtplib.SMTPServerDisconnected: please run connect() first

when I run code that is essentially identical to the code given in

http://docs.python.org/library/email-examples.html

The error happens at the line (copied verbatim from the example
linked to above):

s.sendmail(me, [you], msg.as_string())

What am I doing wrong?

kynn

P.S. I'm running this using v. 2.6.1.

P.S.2. By "essentially identical" I mean that the only change I
made to the original snippet was to initialize variables that are
not initialized in the original (namely, textfile, me, and you)
 
E

Ethan Furman

kj said:
I'm getting the error:

smtplib.SMTPServerDisconnected: please run connect() first

when I run code that is essentially identical to the code given in

http://docs.python.org/library/email-examples.html

The error happens at the line (copied verbatim from the example
linked to above):

s.sendmail(me, [you], msg.as_string())

What am I doing wrong?

kynn

P.S. I'm running this using v. 2.6.1.

P.S.2. By "essentially identical" I mean that the only change I
made to the original snippet was to initialize variables that are
not initialized in the original (namely, textfile, me, and you)

The line preceeding it,

s = smtplib.SMTP()

needs to have an e-mail server specified. E.g.

s = smtplib.SMTP('localhost') # from the 2.5 docs


Hope this helps!

~Ethan~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top