Kmail and GnuPG
There seems to be a bit of a problem with the way that Kmail and GnuPG interact that is somewhat confusing. If you do not have gpg-agent running by default, then Kmail will just tell you that it could not do anything when you try to sign or encrypt a message, giving you the rather unhelpful error, "Bad passphrase."
My solution to this was to use the two following scripts:
The first goes to ~/.kde/env
.
#! /bin/sh eval $(gpg-agent --daemon)
The second goes to ~/.kde/shutdown
.
#! /bin/sh if [ -n "${GPG_AGENT_INFO}" ]; then GPG_AGENT_PID=$(echo ${GPG_AGENT_INFO} | cut -d: -f2) kill ${GPG_AGENT_PID} unset GPG_AGENT_INFO fi
YMMV.