To main content

Set up caff with MTA correctly

Published by Benjamin Marwell on

In my GnuPG article about how to attend a PGP signing party I explained how to set up caff using SMTP (Simple Mail Transfer Protocol). However, using a local Mail Transfer Agent (MTA) is the more elegant solution as SMTP is not a properly supported option and discuraged, according to the caff man page or when setting $CONFIG{'mailer-send'} to any value:

Warning when using $CONFIG{'mailer-send'}

Setting this option is strongly discouraged. Fix your local MTA instead.

This how-to will focus on how to send mails via Google Mail (gmail).

Installation

While I am not using Ubuntu anymore, installing caff will also install exim4 as a MTA. This is not the case on Arch Linux or Manjaro, as it is an optional dependency.

While the German article describes how to install Postfix, for this english version I decided to use postfix on Manjaro. While dma would have been a great choice, too, it currently does not support TLSv1.2 and is thus defunct.

Installing the dependencies
# Using paru on Arch/Manjaro:
paru -Syu signing-party postfix

# Using apt-get on Ubuntu and Debian:
apt-get install signing-party postfix libsasl2-modules exim4_ mailx

The configuration is done in just two files:

/etc/postfix/aliases.conf
root: user

Then reload the changes:

sudo postalias /etc/postfix/aliases
/etc/postfix/sasl_password
smtp.gmail.com:587 myMail@gmail.com:clear-text-password
sudo chmod 0600 /etc/postfix/sasl_password
/etc/postfix/sender_canonical: Mapping your local user
user gmail_user@gmail.com
Reading the settings
sudo postmap /etc/postfix/sender_canonical
/etc/postfix/main.cf: Letting postfix know about the relay conf
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
relayhost = [smtp.gmail.com]:587
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
sender_canonical_maps = hash:/etc/postfix/sender_canonical
Enable the postfix daemon
sudo systemctl enable postfix --now

Testing the mail relay service

Now everything should work.

Testing postfix via gmail
mail -s "subject" my_user@gmail.com
  Write some text here.
  When you are done, press CTRL+d:
  ^D

# check the postfix logs for errors:
journalctl -ru postfix | head -n 10

In case your mail has arrived, you are done!

Configuring CAFF

If not already done, make sure the line $CONFIG{'mailer-send'} is commented. Now use caff as you would normally.

Screenshot of caff example output
Figure 1. Screenshot of caff example output