This page describes how to GPG encrypt and then forward all incoming mail. It should work with any modern UNIX that supports .forward. In particular, this page describes how to GPG encrypt and forward to user@example.org using an already generated GPG key.

First, import your public GPG key (note: your private key should not be copied!) and check it is imported:

$ gpg --import <pubkey.asc
$ gpg --list-keys
# note the key id: e.g, ABCD1234

Next create a forwarding script

$ mkdir -p $HOME/bin
$ cat >$HOME/bin/gpg-forward <<EOF
(echo To: user@example.org;
echo Subject: message from \$(hostname) at \$(date);
echo;
gpg --trust-model always -ear ABCD1234) | sendmail -t
EOF
$ chmod +x $HOME/bin/gpg-forward

Create the .forward file and pip it to the above script

$ cat >$HOME/.forward <<EOF
|$HOME/bin/gpg-forward
EOF

Finally, test it! After this, you should receive an appropriately encrypted message to user@example.org (or whatever you replaced it with):

$ mail $USER
Subject: test
testing
.
EOT

Note, if you have problems, you can run $HOME/bin/gpg-forward directly to observe any warnings or errors.