[Python-bugs-list] smtplib - some bugs in code and documentation too(?!) (PR#357)
snajdr@firma.seznam.cz
snajdr@firma.seznam.cz
Thu, 15 Jun 2000 09:51:52 -0400 (EDT)
--Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Hello,
I need library for communication with SMTP server last week. I looked
for smtplib from Python distribution, but I think that there are a number of
bugs:
1. SMTP object work different then you wrote in documentation
See:http://www.python.org/doc/current/lib/module-smtplib.html
http://www.python.org/doc/current/lib/SMTP-example.html
2. default port is 0 (SMTP() constructor) I think that 25 is better number.
3.default hostname in constructor is ''. I think that 'localhost' is better
choice
4. def connect(self, host='localhost', port = 0). You replace
parameters from constructor! ( def __init__(self,
host = '', port = 0)!) Is it good idea?
Example from Python Library Reference:
[...]
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.connect()
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
[...]
It can't work !
> server = smtplib.SMTP('localhost')
OK, you want connect to localhost and port 0?
No. :-(
> server.set_debuglevel(1)
> server.connect()
You connect to localhost to port 0. It is not good
idea. ;-)
> server.sendmail(fromaddr, toaddrs, msg)
> server.quit()
I have Python 1.5.2 (#21, Aug 31 1999, 17:23:40) [GCC 2.7.2.3] on linux2
(Debian Linux)
--
Best regards
Petr Snajdr
--Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD
Content-Type: text/english;
name="smtplib.py.patch"
Content-Transfer-Encoding: base64
Content-Description: My patch of smtplib
Content-Disposition: attachment; filename="smtplib.py.patch"
KioqIHNtdHBsaWIucHkJVGh1IEp1biAxNSAxMzowMDo1MCAyMDAwCi0tLSBzbXRwbGliMi5weQlU
aHUgSnVuIDE1IDE1OjA5OjM3IDIwMDAKKioqKioqKioqKioqKioqCioqKiAxNjgsMTc0ICoqKioK
ICAgICAgZWhsb19yZXNwID0gTm9uZQogICAgICBkb2VzX2VzbXRwID0gMAogIAohICAgICBkZWYg
X19pbml0X18oc2VsZi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ICAgICAgICAgcHJpbnQgIk9LIgogICAgICAgICAg
ICAgIGxpbmUgPSBzZWxmLmZpbGUucmVhZGxpbmUoKQogICAgICAgICAgICAgIHByaW50IGxpbmUg
CiAgICAgICAgICAgICAgaWYgbGluZSA9PSAnJzoKLS0tIDI1OSwyNjQgLS0tLQo=
--Boundary-=_nWlrBbmQBhCDarzOwKkYHIDdqSCD--