how to make smtplib.SMTP('localhost') work on window xp

Z

zxo102

Hi,
I am trying to use python module smtplib to send my email out on
window xp (localhost).

import smtplib
server = smtplib.SMTP('localhost')

but I got the error information as follows:

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "c:\python24\lib\smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "c:\python24\lib\smtplib.py", line 311, in connect
(code, msg) = self.getreply()
File "c:\python24\lib\smtplib.py", line 355, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
SMTPServerDisconnected: Connection unexpectedly closed

I am not sure what is wrong with it. Should I configure my window xp
somewhere to run smtplib.SMTP('localhost')?

Thanks in advance.

ouyang
 
L

Lawrence D'Oliveiro

In message
zxo102 said:
SMTPServerDisconnected: Connection unexpectedly closed

Does the SMTP server on localhost mention anything about the connection
attempt in its log?

If you telnet/netcat to port 25 on localhost, does anything interesting
happen?
 
Z

zxo102

In message


Does the SMTP server on localhost mention anything about the connection
attempt in its log?

If you telnet/netcat to port 25 on localhost, does anything interesting
happen?

Thanks for your mentioning of the SMTP server on localhost. I did not
install that. After I install a free smtp server downloaded from
http://www.softstack.com/freesmtp.html,
and run the following python script again, everything is fine now.

import smtplib
server = smtplib.SMTP('localhost')
....

Thanks for your message.

ouyang
 
S

Steve Holden

zxo102 said:
Hi,
I am trying to use python module smtplib to send my email out on
window xp (localhost).

import smtplib
server = smtplib.SMTP('localhost')

but I got the error information as follows:

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "c:\python24\lib\smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "c:\python24\lib\smtplib.py", line 311, in connect
(code, msg) = self.getreply()
File "c:\python24\lib\smtplib.py", line 355, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
SMTPServerDisconnected: Connection unexpectedly closed

I am not sure what is wrong with it. Should I configure my window xp
somewhere to run smtplib.SMTP('localhost')?

Thanks in advance.
Well your code certainly expects *something* to be listening on port 25
on localhost. It's fairly unusual to run an SMTP server on Windows XP,
though not impossible.

usually your email system is set up to use some external host as uts
SMPT server: if you look in your mail client's configuration you will
probably find out whihc host you should be using.

regards
Steve
 
Z

zxo102

Well your code certainly expects *something* to be listening on port 25
on localhost. It's fairly unusual to run an SMTP server on Windows XP,
though not impossible.

usually your email system is set up to use some external host as uts
SMPT server: if you look in your mail client's configuration you will
probably find out whihc host you should be using.

regards
Steve

In my case, I implement an application with python to accomplish
collecting real time data from a serial port: com1 which is connected
to some xbee hardwares.
The python logging module is used to save the information generated at
runtime into a log file. Since the site is far away from my office, I
try to
use a smtp server with the python smtplib module to send the log file
into my email account regularly so that I can check it from anywhere.

Thanks for your suggestion.

Ouyang
 
T

Tim Roberts

zxo102 said:
In my case, I implement an application with python to accomplish
collecting real time data from a serial port: com1 which is connected
to some xbee hardwares.
The python logging module is used to save the information generated at
runtime into a log file. Since the site is far away from my office, I
try to
use a smtp server with the python smtplib module to send the log file
into my email account regularly so that I can check it from anywhere.

It's quite likely that the correct solution is for you to use the SMTP
server for the Internet provider at the remote site. When you run your own
SMTP server, it is WAY too easy to leave your configuration open for
spammers to abuse.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top