Subject: Re: bug#20211: 24.4; sendmail.el

From: Richard Ryniker <[email-masked]>
Date: Mon, 30 Mar 2015 11:04:14 -0400

*** emacs-24.4/lisp/mail/sendmail.el	Fri Mar 21 01:34:40 2014
--- /home/ryniker/sendmail.el	Sun Mar 29 17:14:53 2015
***************
*** 1299,1308 ****
                    (error "Sending...failed to %s"
                           (buffer-substring (point-min) (point-max)))))))
        (kill-buffer tembuf)
!       (if (and (bufferp errbuf)
!                (not error))
!           (kill-buffer errbuf)
!         (switch-to-buffer-other-window errbuf)))))
  
  (autoload 'rmail-output-to-rmail-buffer "rmailout")
  
--- 1299,1308 ----
                    (error "Sending...failed to %s"
                           (buffer-substring (point-min) (point-max)))))))
        (kill-buffer tembuf)
!       (when (buffer-live-p errbuf)
!         (if error
!             (switch-to-buffer-other-window errbuf)
!           (kill-buffer errbuf))))))
  
  (autoload 'rmail-output-to-rmail-buffer "rmailout")

Proposed emacs-24.4/lisp/Changelog entry:

2015-03-29  Richard Ryniker  <[email-masked]>

	* mail/sendmail.el (sendmail-send-it): Do not attempt to switch to
	non-existent buffer.  (errbuf is not created when customization
	variable mail-interactive is nil.)

>IIUC "when mail-interactive is true and the sendmail program fails" we
>show the error.  Don't we?

I do not know.  I believe this patch only changes the sendmail.el logic
in the mail-interactive true case to use buffer-live-p instead of
bufferp.  The error I encountered occurs only when mail-interactive is
nil: in this case, errbuf is never created and the attempt to switch to
the non-existant buffer causes a fault.

What errors a Mail User Agent reports synchronously, and what errors are
reported asynchronously via mail from the Mail Transfer Agent, must
depend on the programs actually used.  In my case (using exim) all errors
I have encountered (unknown recipient, malformed address, etc.) seem to
be reported asynchronously by the MTA.  To directly test
mail-intereactive true, I should have to concoct some test sendmail
program that delivers errors as desired.  Not difficult; I can do this if
you think it useful.