I recently had to sign someone’s GPG key. I’ve long used the caff tool from the signing-party package to help me with this. Unfortunately, I’m using a new laptop and hadn’t yet configured caff on it. Moreover, caff uses the system MTA by default, normally found at /usr/sbin/sendmail, and I hadn’t yet properly configured it to send mail to the outside world. Since I have multiple email accounts and use mutt as my mail client, I use msmtp as my SMTP client / sendmail drop-in. This post describes how to configure caff to use msmtp.

Reading the caff man page, one sees the following tantalising hint, which leads you to believe it’s completely trivial to specify your own MTA:

$CONFIG{'mailer-send'} = [ 'sendmail', '-f', $CONFIG{'email'}, '-it' ];

Unfortunately, substituting in a custom path, e.g., /home/rak/bin/msmtp/msmtp-default, for sendmail in the above line results in a long sequence of errors when caff tries to mail the signed keys:

Bareword "home" not allowed while "strict subs" in use at (eval 218) line 1.
Bareword "rak" not allowed while "strict subs" in use at (eval 218) line 1.
Bareword "bin" not allowed while "strict subs" in use at (eval 218) line 1.
Bareword "msmtp" not allowed while "strict subs" in use at (eval 218) line 1.
Bareword "msmtp" not allowed while "strict subs" in use at (eval 218) line 1.
Bareword "default" not allowed while "strict subs" in use at (eval 218) line 1.

Fortunately, it’s still straightforward to accomplish after reading the perldoc for Mail::Mailer. In my case, it was sufficient to add the following to my ~/.caffrc:

$ENV{'PERL_MAILERS'} = 'sendmail:'.$ENV{'HOME'}.'/bin/msmtp/msmtp-default';
$CONFIG{'mailer-send'} = [ 'sendmail' ];

To specify alternate paths to your sendmail-style MTA, simply modify the value of $ENV{'PERL_MAILERS'} after the initial sendmail: bit. If you’re using stock msmtp, I believe the following pair of lines will work, though I haven’t tested it:

$ENV{'PERL_MAILERS'} = 'sendmail:/usr/bin/msmtp';
$CONFIG{'mailer-send'} = [ 'sendmail' ];

If there’s a more elegant way to accomplish this, I’d be happy to hear about it!