diff options
author | Fred Drake <fdrake@acm.org> | 2000-04-03 20:13:55 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-04-03 20:13:55 (GMT) |
commit | 38e5d27caee56b6958e0034e342abb48e6100390 (patch) | |
tree | 6a0c853da853123dd2e628e8ec187517250c2530 /Doc/lib/libsmtplib.tex | |
parent | 659ebfa79e891fc5e2480cd66c157970df57c451 (diff) | |
download | cpython-38e5d27caee56b6958e0034e342abb48e6100390.zip cpython-38e5d27caee56b6958e0034e342abb48e6100390.tar.gz cpython-38e5d27caee56b6958e0034e342abb48e6100390.tar.bz2 |
Merged changes from the 1.5.2p2 release.
(Very rough.)
Diffstat (limited to 'Doc/lib/libsmtplib.tex')
-rw-r--r-- | Doc/lib/libsmtplib.tex | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/Doc/lib/libsmtplib.tex b/Doc/lib/libsmtplib.tex index d366cca..445a417 100644 --- a/Doc/lib/libsmtplib.tex +++ b/Doc/lib/libsmtplib.tex @@ -74,6 +74,17 @@ A nice selection of exceptions is defined as well: \end{excdesc} +\begin{seealso} + \seetext{Internet \rfc{821}, \emph{Simple Mail Transfer Protocol}. + Available online at + \url{http://info.internet.isi.edu/in-notes/rfc/files/rfc821.txt}.} + + \seetext{Internet \rfc{1869}, \emph{SMTP Service Extensions}. + Available online at + \url{http://info.internet.isi.edu/in-notes/rfc/files/rfc1869.txt}.} +\end{seealso} + + \subsection{SMTP Objects \label{SMTP-objects}} An \class{SMTP} instance has the following methods: @@ -160,6 +171,10 @@ need to use different ESMTP options to different recipients you have to use the low-level methods such as \method{mail}, \method{rcpt} and \method{data} to send the message.) +\strong{Note:} The \var{from_addr} and \var{to_addrs} parameters are +used to construct the message envelope used by the transport agents. +The \class{SMTP} does not modify the message headers in any way. + If there has been no previous \samp{EHLO} or \samp{HELO} command this session, this method tries ESMTP \samp{EHLO} first. If the server does ESMTP, message size and each of the specified options will be passed @@ -177,27 +192,25 @@ message sent by the server. This method may raise the following exceptions: -\begin{itemize} +\begin{description} \item[\exception{SMTPRecipientsRefused}] All recipients were refused. Nobody got the mail. The -\var{recipients} attribute of the exception object is a dictionary +\member{recipients} attribute of the exception object is a dictionary with information about the refused recipients (like the one returned when at least one recipient was accepted). \item[\exception{SMTPHeloError}] -The server didn't reply properly to -the helo greeting. +The server didn't reply properly to the \samp{HELO} greeting. \item[\exception{SMTPSenderRefused}] -The server didn't accept the from_addr. +The server didn't accept the \var{from_addr}. \item[\exception{SMTPDataError}] -The server replied with an unexpected -error code (other than a refusal of -a recipient). -\end{itemize} +The server replied with an unexpected error code (other than a refusal +of a recipient). +\end{description} -Unless otherwise noted the connection will be open even after +Unless otherwise noted, the connection will be open even after an exception is raised. \end{methoddesc} @@ -216,33 +229,37 @@ consult the module code. \subsection{SMTP Example \label{SMTP-example}} This example prompts the user for addresses needed in the message -envelop (`To' and `From' addresses), and the message to be +envelope (`To' and `From' addresses), and the message to be delivered. Note that the headers to be included with the message must be included in the message as entered; this example doesn't do any processing of the \rfc{822} headers. In particular, the `To' and `From' addresses must be included in the message headers explicitly. \begin{verbatim} -import rfc822, string, sys import smtplib +import string def prompt(prompt): - sys.stdout.write(prompt + ": ") - return string.strip(sys.stdin.readline()) + return string.strip(raw_input(prompt)) -fromaddr = prompt("From") -toaddrs = string.splitfields(prompt("To"), ',') +fromaddr = prompt("From: ") +toaddrs = string.split(prompt("To: ")) print "Enter message, end with ^D:" -msg = "" + +# Add the From: and To: headers at the start! +msg = ("From: %s\r\nTo: %s\r\n\r\n" + % (fromaddr, string.join(toaddrs, ", "))) while 1: - line = sys.stdin.readline() + line = raw_input() if not line: break msg = msg + line + print "Message length is " + `len(msg)` server = smtplib.SMTP('localhost') server.set_debuglevel(1) +server.connect() server.sendmail(fromaddr, toaddrs, msg) server.quit() \end{verbatim} |