[comp.mail.sendmail] smtpquit

e07@nikhefh.nikhef.nl (Eric Wassenaar) (06/13/91)

If an smtp delivery fails with a temporary error, giveresponse()
uses the value of errno (or SmtpError if zero) to compose a nice
status message. However, to terminate the failing smtp session,
smtpquit() is invoked (possibly recursively), which is likely to
fail also (e.g. if the remote site has closed the channel already),
thereby clobbering the previous value of errno (which may be zero
after a valid 4xx reply).

Since the result status of smtpquit() is never used, one should:
a. Save the value of errno right at the beginning of smtpquit().
b. Restore this value into errno at the exit points of smtpquit().
   (this covers also possible clobbering by the 2 fclose() calls)
c. Clear errno (possibly redundant) at the end of reply() when it
   returns a valid reply.

You will finally see all those 4xx responses that reply() has so
carefully saved in the SmtpError buffer, instead of the dreary
"Connection reset" or "Connection timed out" messages.

To play safe, the store into SmtpError in reply() should better
be done before the call to smtpquit() instead of afterwards.

In addition, a global flag SmtpQuitting could be set in smtpquit()
to be checked by reply() and sfgets(), to suppress unnecessary
error messages to syslog and transcript.

Eric Wassenaar
-- 
Organization: NIKHEF-H, National Institute for Nuclear and High-Energy Physics
Address: Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands
Phone: +31 20 592 0412, Home: +31 20 6909449, Telefax: +31 20 592 5155
Internet: e07@nikhef.nl