Sez The Dragon:

Ok, I fixed the quotes, along with a bug or two.
	Also added another exception.
This commit is contained in:
Guido van Rossum 1998-01-29 17:26:45 +00:00
parent bbe323e52c
commit fc40a8316a
1 changed files with 25 additions and 24 deletions

View File

@ -35,6 +35,7 @@ SMTP_PORT = 25
CRLF="\r\n"
# used for exceptions
SMTPServerDisconnected="Server not connected"
SMTPSenderRefused="Sender address refused"
SMTPRecipientsRefused="All Recipients refused"
SMTPDataError="Error transmoitting message data"
@ -89,7 +90,10 @@ class SMTP:
def send(self, str):
"""Send `str' to the server."""
if self.debuglevel > 0: print 'send:', `str`
if self.sock:
self.sock.send(str)
else:
raise SMTPServerDisconnected
def putcmd(self, cmd, args=""):
"""Send a command to the server.
@ -104,9 +108,8 @@ class SMTP:
- server response code (e.g. '250', or such, if all goes well)
Note: returns -1 if it can't read responce code.
- server response string corresponding to response code
(note : multiline responces converted to a single, multiline
string)
(note : multiline responces converted to a single,
multiline string)
"""
resp=[]
self.file = self.sock.makefile('rb')
@ -207,24 +210,22 @@ class SMTP:
- to_addrs : a list of addresses to send this mail to
- msg : the message to send.
This method will return normally if the mail is accepted for at
least one recipiant .Otherwise it will throw an exception (either
SMTPSenderRefused,SMTPRecipientsRefused, or SMTPDataError)
This method will return normally if the mail is accepted for at least
one recipiant.
Otherwise it will throw an exception (either SMTPSenderRefused,
SMTPRecipientsRefused, or SMTPDataError)
That is, if this method does not throw an excception, then someone
That is, if this method does not throw an exception, then someone
should get your mail.
It returns a dictionary , with one entry for each recipient that
was refused.
It returns a dictionary , with one entry for each recipient that was
refused.
example:
>>> import smtplib
>>> s=smtplib.SMTP("localhost")
>>> tolist= [ "one@one.org",
... "two@two.org",
... "three@three.org",
... "four@four.org"]
>>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
>>> msg = '''
... From: Me@my.org
... Subject: testin'...
@ -234,10 +235,10 @@ class SMTP:
{ "three@three.org" : ( 550 ,"User unknown" ) }
>>> s.quit()
In the above example, the message was accepted for delivery to three
of the four addresses, and one was rejected, with the error code 550.
If all addresses are accepted, then the method will return an
empty dictionary.
In the above example, the message was accepted for delivery to
three of the four addresses, and one was rejected, with the error
code 550. If all addresses are accepted, then the method
will return an empty dictionary.
"""
if not self.helo_resp:
@ -250,7 +251,7 @@ class SMTP:
for each in to_addrs:
(code,resp)=self.rcpt(each)
if (code <> 250) and (code <> 251):
senderr[each]=(code,resp)
senderrs[each]=(code,resp)
if len(senderrs)==len(to_addrs):
#th' server refused all our recipients
self.rset()