[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Can't Connect To SMTP

Dennis Lee Bieber

2/24/2010 6:41:00 PM

On Wed, 24 Feb 2010 10:32:43 -0400, Victor Subervi
<victorsubervi@gmail.com> declaimed the following in
gmane.comp.python.general:

> Hi;
> I'm getting this error:
>
> A problem occurred in a Python script. Here is the sequence of function
> calls leading up to the error, in the order they occurred.
>
Unfortunately, the intermingling of code and mystery output makes it
very difficult to tell what is happening anywhere...

> /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py
> 52 </head>
> 53 <body>'''
> 54 my_mail()
> 55 print '''
> 56 </body>
> my_mail = <function my_mail>
> /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py in my_mail()

Like where is that being output? After all, you are calling
my_mail() two lines further up...

> 33 to_address = ourEmail1,

And now we have line numbers coming from somewhere else -- but no
complete code to compare against.

> 34 subject = subject,
> 35 message = message
> 36 ).send()
> 37 Email(
> message = 'Name: beno -\nMessage: test'
> /var/www/html/globalsolutionsgroup.vi/simplemail/simplemail.py in
> send(self=<simplemail.Email object>)
> 344 smtp = smtplib.SMTP()
> 345 if self.smtp_server:
> 346 smtp.connect(self.smtp_server)
> 347 else:
> 348 smtp.connect()
> smtp = <smtplib.SMTP instance>, smtp.connect = <bound method SMTP.connect of
> <smtplib.SMTP instance>>, self = <simplemail.Email object>, self.smtp_server
> = 'localhost'
> /usr/lib64/python2.4/smtplib.py in connect(self=<smtplib.SMTP instance>,
> host='localhost', port=25)
> 305 if not self.sock:
> 306 raise socket.error, msg
> 307 (code, msg) = self.getreply()
> 308 if self.debuglevel > 0: print>>stderr, "connect:", msg
> 309 return (code, msg)
> code undefined, msg = 'getaddrinfo returns an empty list', self =
> <smtplib.SMTP instance>, self.getreply = <bound method SMTP.getreply of
> <smtplib.SMTP instance>>
> /usr/lib64/python2.4/smtplib.py in getreply(self=<smtplib.SMTP instance>)
> 349 if line == '':
> 350 self.close()
> 351 raise SMTPServerDisconnected("Connection unexpectedly
> closed")
> 352 if self.debuglevel > 0: print>>stderr, 'reply:',
> repr(line)
> 353 resp.append(line[4:].strip())
> global SMTPServerDisconnected = <class smtplib.SMTPServerDisconnected>
> SMTPServerDisconnected: Connection unexpectedly closed
> args = ('Connection unexpectedly closed',)
>
> I'm having a hard time reading this and making sense of it. Please help me
> understand where I should look to fix the problem.

Normal advice is to trim your program down to the absolute minimum
that reproduces your problem, and post that, with a traceback if such is
produced...

Snippets of code interspersed by out-of-sync debug print statements
(no where in the above is ANY statement producing the displayed output
seen).

Second approach... Get a copy of the SMTP RFCs, open a command
console (NOT PYTHON)

telnet localhost 25

and try to follow the RFCs to handshake and form a message... See if the
SMTPd disconnects on you. If you can't create/send a message via telnet,
nothing you do in Python is going to help. And note that the message
indicates that it is the SMTPd that is dropping you...

--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/