Hello,
I'm trying to send a PGP-encrypted email using the mail command. The
problem is my mail client (mutt) doesn't recognize it as a PGP-encrypted
email. I'm sending the email like so:
echo "encrypted msg" | gpg -e -f key | mail -s "test" [email protected]
I think it's because the content-type is not set. Is there a way to do
this?
With OpenBSD mail(1) you can use my patches:
https://en.roquesor.com/Downloads/mail_patches.tar.gz
The add_headers.diff allows you to add any header from the command line
(option '-a').
Then use something like the following in a shell script:
---------------------------------8<-------------------------------------
echo "Hello, world!" | gpg -e --armor -r <key> > encrypted_message
cat << EOT > message
--foo
Content-Type: application/pgp-encrypted
Version: 1
--foo
Content-Type: application/octet-stream
EOT
cat encrypted_message >> message
printf "\n--foo--\n" >> message
mail -s Test \
-a 'MIME-Version: 1.0' \
-a 'Content-Type: multipart/encrypted; boundary="foo";
protocol="application/pgp-encrypted"' \
[email protected] < message
--------------------------------->8-------------------------------------
This already resembles "suckless" software; you have to rack your brains
applying patches and compiling to get features that seem essential. But
that's okay, I'm sure they had a good reason for not adding this
feature. After all, almost no one encrypts their emails these days.