diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-01-15 01:36:40 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-01-15 01:36:40 (GMT) |
commit | 495ad3c8ccb9ed3554177a3e8687676c78e667de (patch) | |
tree | d19e1856ac8aa7f3059ef66646d316393752da90 /Lib/smtplib.py | |
parent | 0c9886d589ddebf32de0ca3f027a173222ed383a (diff) | |
download | cpython-495ad3c8ccb9ed3554177a3e8687676c78e667de.zip cpython-495ad3c8ccb9ed3554177a3e8687676c78e667de.tar.gz cpython-495ad3c8ccb9ed3554177a3e8687676c78e667de.tar.bz2 |
Whitespace normalization.
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-x | Lib/smtplib.py | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 064a9f8..b608840 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -36,7 +36,7 @@ Example: # Eric S. Raymond <esr@thyrsus.com> # Better RFC 821 compliance (MAIL and RCPT, and CRLF in data) # by Carey Evans <c.evans@clear.net.nz>, for picky mail servers. -# +# # This was modified from the Python 1.5 library HTTP lib. import socket @@ -48,7 +48,7 @@ import types SMTP_PORT = 25 CRLF="\r\n" -# Exception classes used by this module. +# Exception classes used by this module. class SMTPException(Exception): """Base class for all exceptions raised by this module.""" @@ -89,8 +89,8 @@ class SMTPSenderRefused(SMTPResponseException): class SMTPRecipientsRefused(SMTPException): """All recipient addresses refused. The errors for each recipient are accessible through the attribute - 'recipients', which is a dictionary of exactly the same sort as - SMTP.sendmail() returns. + 'recipients', which is a dictionary of exactly the same sort as + SMTP.sendmail() returns. """ def __init__(self, recipients): @@ -137,27 +137,27 @@ def quotedata(data): class SMTP: """This class manages a connection to an SMTP or ESMTP server. SMTP Objects: - SMTP objects have the following attributes: - helo_resp - This is the message given by the server in response to the + SMTP objects have the following attributes: + helo_resp + This is the message given by the server in response to the most recent HELO command. - + ehlo_resp - This is the message given by the server in response to the + This is the message given by the server in response to the most recent EHLO command. This is usually multiline. - does_esmtp + does_esmtp This is a True value _after you do an EHLO command_, if the server supports ESMTP. - esmtp_features + esmtp_features This is a dictionary, which, if the server supports ESMTP, will _after you do an EHLO command_, contain the names of the SMTP service extensions this server supports, and their parameters (if any). - Note, all extension names are mapped to lower case in the - dictionary. + Note, all extension names are mapped to lower case in the + dictionary. See each method's docstrings for details. In general, there is a method of the same name to perform each SMTP command. There is also a @@ -183,7 +183,7 @@ class SMTP: (code, msg) = self.connect(host, port) if code != 220: raise SMTPConnectError(code, msg) - + def set_debuglevel(self, debuglevel): """Set the debug output level. @@ -222,7 +222,7 @@ class SMTP: (code,msg)=self.getreply() if self.debuglevel >0 : print "connect:", msg return (code,msg) - + def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` @@ -235,7 +235,7 @@ class SMTP: raise SMTPServerDisconnected('Server not connected') else: raise SMTPServerDisconnected('please run connect() first') - + def putcmd(self, cmd, args=""): """Send a command to the server.""" if args == "": @@ -243,10 +243,10 @@ class SMTP: else: str = '%s %s%s' % (cmd, args, CRLF) self.send(str) - + def getreply(self): """Get a reply from the server. - + Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) @@ -280,10 +280,10 @@ class SMTP: break errmsg = string.join(resp,"\n") - if self.debuglevel > 0: + if self.debuglevel > 0: print 'reply: retcode (%s); Msg: %s' % (errcode,errmsg) return errcode, errmsg - + def docmd(self, cmd, args=""): """Send a command, and return its response code.""" self.putcmd(cmd,args) @@ -313,8 +313,8 @@ class SMTP: else: self.putcmd("ehlo", socket.getfqdn()) (code,msg)=self.getreply() - # According to RFC1869 some (badly written) - # MTA's will disconnect on an ehlo. Toss an exception if + # According to RFC1869 some (badly written) + # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == -1 and len(msg) == 0: raise SMTPServerDisconnected("Server not connected") @@ -368,7 +368,7 @@ class SMTP: return self.getreply() def data(self,msg): - """SMTP 'DATA' command -- sends message data to server. + """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. Raises SMTPDataError if there is an unexpected reply to the @@ -404,14 +404,14 @@ class SMTP: # some useful methods def sendmail(self, from_addr, to_addrs, msg, mail_options=[], - rcpt_options=[]): - """This command performs an entire mail transaction. + rcpt_options=[]): + """This command performs an entire mail transaction. - The arguments are: + The arguments are: - from_addr : The address sending this mail. - to_addrs : A list of addresses to send this mail to. A bare string will be treated as a list with 1 address. - - msg : The message to send. + - msg : The message to send. - mail_options : List of ESMTP options (such as 8bitmime) for the mail command. - rcpt_options : List of ESMTP options (such as DSN commands) for @@ -430,7 +430,7 @@ class SMTP: This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to - the helo greeting. + the helo greeting. SMTPRecipientsRefused The server rejected ALL recipients (no mail was sent). SMTPSenderRefused The server didn't accept the from_addr. @@ -441,7 +441,7 @@ class SMTP: Note: the connection will be open even after an exception is raised. Example: - + >>> import smtplib >>> s=smtplib.SMTP("localhost") >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"] @@ -453,7 +453,7 @@ class SMTP: >>> s.sendmail("me@my.org",tolist,msg) { "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 @@ -494,7 +494,7 @@ class SMTP: self.rset() raise SMTPDataError(code, resp) #if we got here then somebody got our mail - return senderrs + return senderrs def close(self): |