Subject: Re: bug#25040: 24.5; setting mail-interactive to nil causes error while sending

From: Francesco Potortì <[email-masked]>
Date: Sun, 27 Nov 2016 16:00:27 +0100

>> In sendmail.el I find this:
>>
>> ================
>> (defun sendmail-send-it ()
>>   "Send the current mail buffer using the Sendmail package.
>> This is a suitable value for `send-mail-function'.  It sends using the
>> external program defined by `sendmail-program'."
>>   (require 'mail-utils)
>>   (let ((errbuf (if mail-interactive
>>                     (generate-new-buffer " sendmail errors")
>>                   0))
>> ================
>>
>> However, the final 0 makes no sense to me, and in fact it generates an
>> error when sending mail if mail-interactive is set to nil.
>>
>> Changing the 0 to nil apparently corrects the problem.
>
>Can you show the error backtrace? It looks like errbuf is unused when
>mail-interactive is nil except for the call to call-process-region
>where it acts as the BUFFER argument
>
>    Insert output in BUFFER before point; t means current buffer; nil for
>     BUFFER means discard it; 0 means discard and don’t wait

I was too hasty, sorry about that.  Anyway, the problem exists, but it
is different from what I have told.  0 can be put back there.

Apparently this change at the end of the functions fixes the bug:

1302,1305c1302,1305
<       (if (and (bufferp errbuf)
<                (not error))
<           (kill-buffer errbuf)
<         (switch-to-buffer-other-window errbuf)))))
---
>       (when (bufferp errbuf)
> 	(if (not error)
> 	    (kill-buffer errbuf)
> 	  (switch-to-buffer-other-window errbuf))))))