[Tutor] smtplib broken in python 2.3?

Baker.Michael.B Michael.Baker at IGT.com
Wed Mar 10 14:11:40 EST 2004


i'm running winXP Pro and this code:
 
from smtplib import *
import sys
 
def prompt(prompt):
    sys.stdout.write(prompt + ": ")
    return sys.stdin.readline().strip()
 
fromaddr = prompt("From")
toaddrs  = prompt("To").split(',')
print "Enter message, end with ^D:"
msg = ''
while 1:
    line = sys.stdin.readline()
    if not line:
        break
    msg = msg + line
print "Message length is " + `len(msg)`
 
server = SMTP('RNOEXCH05', 25)
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
 
ok in 2.2, but fail in 2.3:
 
Traceback (most recent call last):
  File "C:/Python23/email.py", line 1, in -toplevel-
    from smtplib import *
  File "C:\Python23\lib\smtplib.py", line 49, in -toplevel-
    from email.base64MIME import encode as encode_base64
  File "C:/Python23\email.py", line 19, in -toplevel-
    server = SMTP('RNOEXCH05', 25)
NameError: name 'SMTP' is not defined
 
also strange:
 
2.2:
 
>>> dir(smtplib)
['CRLF', 'OLDSTYLE_AUTH', 'SMTP', 'SMTPAuthenticationError',
'SMTPConnectError', 'SMTPDataError', 'SMTPException', 'SMTPHeloError',
'SMTPRecipientsRefused', 'SMTPResponseException', 'SMTPSenderRefused',
'SMTPServerDisconnected', 'SMTP_PORT', 'SSLFakeFile', 'SSLFakeSocket',
'__all__', '__builtins__', '__doc__', '__file__', '__name__', 'base64',
'encode_base64', 'hmac', 'quoteaddr', 'quotedata', 're', 'rfc822', 'socket',
'types']
 
2.3:
 
>>> dir(smtplib)
['__builtins__', '__doc__', '__file__', '__name__', 'base64', 'hmac', 're',
'rfc822', 'socket']

what am i missing??? thanks in advance :)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040310/d41e7d5f/attachment.html


More information about the Tutor mailing list