* message.el (message-send-mail-with-sendmail): Kill errbuf even if sending
authorKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 12 Jun 2002 08:40:36 +0000 (08:40 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 12 Jun 2002 08:40:36 +0000 (08:40 +0000)
 failed.

lisp/ChangeLog
lisp/message.el

index cf58f25..b2dc0df 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-12  Katsumi Yamaoka <yamaoka@jpl.org>
+
+       * message.el (message-send-mail-with-sendmail): Kill errbuf even
+       if sending failed.
+
 2002-06-11  Josh Huber  <huber@alum.wpi.edu>
 
        * gnus-start.el (gnus-dribble-enter): Don't call set-window-point anymore
index 7fe95de..07c2e23 100644 (file)
@@ -2970,64 +2970,67 @@ If you always want Gnus to send messages in one piece, set
                     " sendmail errors")
                  0))
        resend-to-addresses delimline)
-    (let ((case-fold-search t))
-      (save-restriction
-       (message-narrow-to-headers)
-       (setq resend-to-addresses (message-fetch-field "resent-to")))
-      ;; Change header-delimiter to be what sendmail expects.
-      (goto-char (point-min))
-      (re-search-forward
-       (concat "^" (regexp-quote mail-header-separator) "\n"))
-      (replace-match "\n")
-      (backward-char 1)
-      (setq delimline (point-marker))
-      (run-hooks 'message-send-mail-hook)
-      ;; Insert an extra newline if we need it to work around
-      ;; Sun's bug that swallows newlines.
-      (goto-char (1+ delimline))
-      (when (eval message-mailer-swallows-blank-line)
-       (newline))
-      (when message-interactive
-       (save-excursion
-         (set-buffer errbuf)
-         (erase-buffer))))
-    (let ((default-directory "/")
-         (coding-system-for-write message-send-coding-system))
-      (let ((cpr
-            (apply 'call-process-region
-                   (append (list (point-min) (point-max)
-                                 (if (boundp 'sendmail-program)
-                                     sendmail-program
-                                   "/usr/lib/sendmail")
-                                 nil errbuf nil "-oi")
-                           ;; Always specify who from,
-                           ;; since some systems have broken sendmails.
-                           ;; But some systems are more broken with -f, so
-                           ;; we'll let users override this.
-                           (if (null message-sendmail-f-is-evil)
-                               (list "-f" (message-make-address)))
-                           ;; These mean "report errors by mail"
-                           ;; and "deliver in background".
-                           (if (null message-interactive) '("-oem" "-odb"))
-                           ;; Get the addresses from the message
-                           ;; unless this is a resend.
-                           ;; We must not do that for a resend
-                           ;; because we would find the original addresses.
-                           ;; For a resend, include the specific addresses.
-                           (if resend-to-addresses
-                               (list resend-to-addresses)
-                             '("-t"))))))
-       (unless (or (null cpr) (zerop cpr))
-         (error "Sending...failed with exit value %d" cpr))))
-    (when message-interactive
-      (save-excursion
-       (set-buffer errbuf)
-       (goto-char (point-min))
-       (while (re-search-forward "\n\n* *" nil t)
-         (replace-match "; "))
-       (if (not (zerop (buffer-size)))
-           (error "Sending...failed to %s"
-                  (buffer-substring (point-min) (point-max)))))
+    (unwind-protect
+       (progn
+         (let ((case-fold-search t))
+           (save-restriction
+             (message-narrow-to-headers)
+             (setq resend-to-addresses (message-fetch-field "resent-to")))
+           ;; Change header-delimiter to be what sendmail expects.
+           (goto-char (point-min))
+           (re-search-forward
+            (concat "^" (regexp-quote mail-header-separator) "\n"))
+           (replace-match "\n")
+           (backward-char 1)
+           (setq delimline (point-marker))
+           (run-hooks 'message-send-mail-hook)
+           ;; Insert an extra newline if we need it to work around
+           ;; Sun's bug that swallows newlines.
+           (goto-char (1+ delimline))
+           (when (eval message-mailer-swallows-blank-line)
+             (newline))
+           (when message-interactive
+             (save-excursion
+               (set-buffer errbuf)
+               (erase-buffer))))
+         (let* ((default-directory "/")
+                (coding-system-for-write message-send-coding-system)
+                (cpr (apply
+                      'call-process-region
+                      (append
+                       (list (point-min) (point-max)
+                             (if (boundp 'sendmail-program)
+                                 sendmail-program
+                               "/usr/lib/sendmail")
+                             nil errbuf nil "-oi")
+                       ;; Always specify who from,
+                       ;; since some systems have broken sendmails.
+                       ;; But some systems are more broken with -f, so
+                       ;; we'll let users override this.
+                       (if (null message-sendmail-f-is-evil)
+                           (list "-f" (message-make-address)))
+                       ;; These mean "report errors by mail"
+                       ;; and "deliver in background".
+                       (if (null message-interactive) '("-oem" "-odb"))
+                       ;; Get the addresses from the message
+                       ;; unless this is a resend.
+                       ;; We must not do that for a resend
+                       ;; because we would find the original addresses.
+                       ;; For a resend, include the specific addresses.
+                       (if resend-to-addresses
+                           (list resend-to-addresses)
+                         '("-t"))))))
+           (unless (or (null cpr) (zerop cpr))
+             (error "Sending...failed with exit value %d" cpr)))
+         (when message-interactive
+           (save-excursion
+             (set-buffer errbuf)
+             (goto-char (point-min))
+             (while (re-search-forward "\n\n* *" nil t)
+               (replace-match "; "))
+             (if (not (zerop (buffer-size)))
+                 (error "Sending...failed to %s"
+                        (buffer-substring (point-min) (point-max)))))))
       (when (bufferp errbuf)
        (kill-buffer errbuf)))))