Revision 296e14301a7aa23a5ee2bfaa1210af54e594cbbf authored by Guido van Rossum on 07 April 1999, 15:03:39 UTC, committed by Guido van Rossum on 07 April 1999, 15:03:39 UTC
Per writes: """ The application where Signum Support uses smtplib needs to be able to report good error messages to the user when sending email fails. To help in diagnosing problems it is useful to be able to report the entire message sent by the server, not only the SMTP error code of the offending command. A lot of the functions in sendmail.py unfortunately discards the message, leaving only the code. The enclosed patch fixes that problem. The enclosed patch also introduces a base class for exceptions that include an SMTP error code and error message, and make the code and message available on separate attributes, so that surrounding code can deal with them in whatever way it sees fit. I've also added some documentation to the exception classes. The constructor will now raise an exception if it cannot connect to the SMTP server. The data() method will raise an SMTPDataError if it doesn't receive the expected 354 code in the middle of the exchange. According to section 5.2.10 of RFC 1123 a smtp client must accept "any text, including no text at all" after the error code. If the response of a HELO command contains no text self.helo_resp will be set to the empty string (""). The patch fixes the test in the sendmail() method so that helo_resp is tested against None; if it has the empty string as value the sendmail() method would invoke the helo() method again. The code no longer accepts a -1 reply from the ehlo() method in sendmail(). [Text about removing SMTPRecipientsRefused deleted --GvR] """ and also: """ smtplib.py appends an extra blank line to the outgoing mail if the `msg' argument to the sendmail method already contains a trailing newline. This patch should fix the problem. """ The Dragon writes: """ Mostly I just re-added the SMTPRecipientsRefused exception (the exeption object now has the appropriate info in it ) [Per had removed this in his patch --GvR] and tweaked the behavior of the sendmail method whence it throws the newly added SMTPHeloException (it was closing the connection, which it shouldn't. whatever catches the exception should do that. ) I pondered the change of the return values to tuples all around, and after some thinking I decided that regularizing the return values was too much of the Right Thing (tm) to not do. My one concern is that code expecting an integer & getting a tuple may fail silently. (i.e. if it's doing : x.somemethod() >= 400: expecting an integer, the expression will always be true if it gets a tuple instead. ) However, most smtplib code I've seen only really uses the sendmail() method, so this wouldn't bother it. Usually code I've seen that calls the other methods usually only calls helo() and ehlo() for doing ESMTP, a feature which was not in the smtplib included with 1.5.1, and thus I would think not much code uses it yet. """
1 parent 630a9a6
config.h
/* Include/config.h. Generated automatically by configure. */
/* NOTE: config.h.in is converted into config.h by the configure
script in the toplevel directory.
On non-UNIX systems, manually copy config.h.in to config.h, and
edit the latter to reflect the actual configuration of your system.
Then arrange that the symbol HAVE_CONFIG_H is defined during
compilation (usually by passing an argument of the form
`-DHAVE_CONFIG_H' to the compiler, but this is necessarily
system-dependent). */
/* Types which have no traditional name -- edit the definition if necessary */
#define RETSIGTYPE void /* int or void: return of signal handlers */
/* Types which are often defined in <sys/types.h> -- either define as
some variant of int or leave undefined. Uncomment a definition if
your <sys/types.h> does not define the type */
/* #define mode_t int */
/* #define off_t long */
/* #define pid_t int */
/* #define size_t unsigned */
/* #define uid_t int */
/* #define gid_t int */
/* Feature test symbols -- either define as 1 or leave undefined */
/* symbol name: #define as 1 if: */
/* #undef STDC_HEADERS */ /* the standard C header files exist
(in particular, <stdlib.h>,
<stdarg.h>, <string.h> and <float.h>) */
/* #undef HAVE_DLFCN_H */ /* <dlfcn.h> exists */
#define HAVE_SIGNAL_H 1 /* <signal.h> exists */
#define HAVE_STDARG_H 1 /* <stdarg.h> exists (else need <varargs.h>) */
#define HAVE_STDLIB_H 1 /* <stdlib.h> exists */
#define HAVE_UNISTD_H 1 /* <unistd.h> exists */
#define HAVE_UTIME_H 1 /* <utime.h> exists */
#define HAVE_SYS_PARAM_H 1 /* <sys/param.h> exists */
/* #undef HAVE_SYS_SELECT_H */ /* <sys/select.h> exists */
#define HAVE_SYS_TIMES_H 1 /* <sys/times.h> exists */
/* #undef HAVE_SYS_TIME_H */ /* <sys/time.h> exists */
#define HAVE_SYS_UTSNAME_H 1 /* <sys.utsname.h> exists */
#define TIME_WITH_SYS_TIME 1 /* <sys/time.h> and <time.h> can be included
together */
/* #undef HAVE_TM_ZONE */ /* struct tm has a tm_zone member */
#define HAVE_TZNAME 1 /* extern char *tzname[] exists */
#define HAVE_CLOCK 1 /* clock() exists */
/* #undef HAVE_FTIME */ /* ftime() exists */
#define HAVE_GETPGRP 1 /* getpgrp() exists */
#define HAVE_GETTIMEOFDAY 1 /* gettimeofday() exists */
#define HAVE_LSTAT 1 /* lstat() exists */
#define HAVE_PROTOTYPES 1 /* the compiler understands prototypes */
#define HAVE_READLINK 1 /* readlink() exists */
#define HAVE_SELECT 1 /* select() exists */
#define HAVE_SETPGID 1 /* setpgid() exists */
#define HAVE_SETPGRP 1 /* setpgrp() exists */
#define HAVE_SETSID 1 /* setsid() exists */
#define HAVE_SYMLINK 1 /* symlink() exists */
/* #undef HAVE_SIGINTERRUPT */ /* siginterrupt() exists */
#define HAVE_TCGETPGRP 1 /* tcgetpgrp() exists */
#define HAVE_TCSETPGRP 1 /* tcsetpgrp() exists */
#define HAVE_TIMES 1 /* times() exists */
#define HAVE_UNAME 1 /* uname() exists */
#define HAVE_WAITPID 1 /* waitpid() exists */
/* #undef GETPGRP_HAVE_ARG */ /* getpgrp() must be called as getpgrp(0)
(and setpgrp() as setpgrp(0, 0)) */
#define WITH_READLINE 1 /* GNU readline() should be used */
/* #undef USE_THREAD */ /* Build in thread support */
/* #undef SOLARIS */ /* This is SOLARIS 2.x */
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...