On Fri, Oct 17, 2025 at 08:35:03PM +0800, W. D. Sadeep wrote:
> 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-------------------------------------

-- 
Walter

Reply via email to