With the attached (the first test from T355-smime.sh) saved as foo.sh, try running the following. count=0; while ./foo.sh ; do count=$((count + 1)) echo $count >> tests.log done After the somewhere between 1 and 200 iterations this hangs up for me. Emacs is still running, the message-mode buffer has appropriate looking stuff in it. There is nothing interesting in *Messages*, and the buffer is still titled "*unsent mail*". When sending manually, I get a message that there is no key for test_suite@notmuchmail.org After digging through mml-secure for a while, I realized that the problem is not actually in emacs, but in our test harness for gpgsm. I added the gpgsm -K to the script, and you can see that the test_suite@notmuchmail.org key is not being added. I think that means there is some kind of intermittent failure with the following pipeline openssl pkcs12 -export -passout pass: -inkey "$NOTMUCH_SRCDIR/test/smime/key+cert.pem" \ < "$NOTMUCH_SRCDIR/test/smime/test.crt" | \ gpgsm --batch --no-tty --no-common-certs-import --pinentry-mode=loopback --passphrase-fd 3 \ --disable-dirmngr --import >"$GNUPGHOME"/import.log 2>&1 3<<<'' I've attached "import.log". I _think_ the failure reported is the notmuchmail.org key, and the success is the 'Bob Babbage' key,