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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zxo102

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

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

    import smtplib
    server = smtplib.SMTP('l ocalhost')

    but I got the error information as follows:

    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in ?
    File "c:\python24\li b\smtplib.py", line 244, in __init__
    (code, msg) = self.connect(ho st, port)
    File "c:\python24\li b\smtplib.py", line 311, in connect
    (code, msg) = self.getreply()
    File "c:\python24\li b\smtplib.py", line 355, in getreply
    raise SMTPServerDisco nnected("Connec tion unexpectedly closed")
    SMTPServerDisco nnected: Connection unexpectedly closed

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

    Thanks in advance.

    ouyang
  • Lawrence D'Oliveiro

    #2
    Re: how to make smtplib.SMTP('l ocalhost') work on window xp

    In message
    <56f2097a-5129-4d1a-be82-a73e2874ba04@p3 1g2000prf.googl egroups.com>, zxo102
    wrote:
    SMTPServerDisco nnected: 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?

    Comment

    • zxo102

      #3
      Re: how to make smtplib.SMTP('l ocalhost') work on window xp

      On 9ÔÂ29ÈÕ, ÏÂÎç2ʱ53·Ö, Lawrence D'Oliveiro <l...@geek-
      central.gen.new _zealandwrote:
      In message
      <56f2097a-5129-4d1a-be82-a73e2874b...@p3 1g2000prf.googl egroups.com>, zxo102
      wrote:
      >
      SMTPServerDisco nnected: 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?
      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('l ocalhost')
      ....

      Thanks for your message.

      ouyang


      Comment

      • Steve Holden

        #4
        Re: how to make smtplib.SMTP('l ocalhost') work on window xp

        zxo102 wrote:
        Hi,
        I am trying to use python module smtplib to send my email out on
        window xp (localhost).
        >
        import smtplib
        server = smtplib.SMTP('l ocalhost')
        >
        but I got the error information as follows:
        >
        Traceback (most recent call last):
        File "<interacti ve input>", line 1, in ?
        File "c:\python24\li b\smtplib.py", line 244, in __init__
        (code, msg) = self.connect(ho st, port)
        File "c:\python24\li b\smtplib.py", line 311, in connect
        (code, msg) = self.getreply()
        File "c:\python24\li b\smtplib.py", line 355, in getreply
        raise SMTPServerDisco nnected("Connec tion unexpectedly closed")
        SMTPServerDisco nnected: Connection unexpectedly closed
        >
        I am not sure what is wrong with it. Should I configure my window xp
        somewhere to run smtplib.SMTP('l ocalhost')?
        >
        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

        --
        Steve Holden +1 571 484 6266 +1 800 494 3119
        Holden Web LLC http://www.holdenweb.com/

        Comment

        • zxo102

          #5
          Re: how to make smtplib.SMTP('l ocalhost') work on window xp

          On 9ÔÂ29ÈÕ, ÏÂÎç7ʱ29·Ö, Steve Holden <st...@holdenwe b.comwrote:
          zxo102 wrote:
          Hi,
          I am trying to use python module smtplib to send my email out on
          window xp (localhost).
          >
          import smtplib
          server = smtplib.SMTP('l ocalhost')
          >
          but I got the error information as follows:
          >
          Traceback (most recent call last):
          File "<interacti ve input>", line 1, in ?
          File "c:\python24\li b\smtplib.py", line 244, in __init__
          (code, msg) = self.connect(ho st, port)
          File "c:\python24\li b\smtplib.py", line 311, in connect
          (code, msg) = self.getreply()
          File "c:\python24\li b\smtplib.py", line 355, in getreply
          raise SMTPServerDisco nnected("Connec tion unexpectedly closed")
          SMTPServerDisco nnected: Connection unexpectedly closed
          >
          I am not sure what is wrong with it. Should I configure my window xp
          somewhere to run smtplib.SMTP('l ocalhost')?
          >
          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
          >
          --
          Steve Holden +1 571 484 6266 +1 800 494 3119
          Holden Web LLC http://www.holdenweb.com/
          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

          Comment

          • Tim Roberts

            #6
            Re: how to make smtplib.SMTP('l ocalhost') work on window xp

            zxo102 <zxo102@gmail.c omwrote:
            >
            >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.
            --
            Tim Roberts, timr@probo.com
            Providenza & Boekelheide, Inc.

            Comment

            Working...