Subject: bug#56855: 27.1; sendmail-send-it considers it an error if sendmail wrote to stdout/stderr

From: Justus Winter <[email-masked]>
Date: Sun, 31 Jul 2022 15:08:28 +0200

sendmail-send-it considers it an error if sendmail wrote to
stdout/stderr, despite the fact that the process returned success.

I use msmtp with the authentication password encrypted using OpenPGP.
Then, I use 'gpg --no-tty -q -d ...' as msmtp's passwordeval function.
Now, my OpenPGP key has expired, but that doesn't stop GnuPG from
decrypting the secret, and in fact it returns the status code 0.  It
also prints

  gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 25 Jul 2022 05:31:26 PM CEST

to stderr, which is picked up by emacs, it says

  sending...failed to gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 25 Jul 2022 05:31:26 PM CEST

in the status buffer while the compose buffer stays open.  Note that
despite this, the message has been sent successfully, while emacs
indicates that the sending has failed.

I wrote to the notmuch mailing list before investigating further, and at
least one other person hat a similar problem.  The thread is here:

https://nmbug.notmuchmail.org/nmweb/show/87k080jgx8.fsf%40thinkbox

I dug into emacs, and discovered that indeed sendmail-send-it considers
any output from the sendmail process to be an indication of an error,
even if the process returned 0.  I read documentation of various
sendmail implementations, and all agreed that returning success meant
that the operation succeeded.  I found no justification for emacs
thinking that the operation failed if the process printed to stdout or
stderr.

Best,
Justus