From sadeep at asciimx.com Sun Oct 19 03:50:42 2025 From: sadeep at asciimx.com (W. D. Sadeep) Date: Sun, 19 Oct 2025 11:50:42 +0800 Subject: How to send a PGP-encrypted email from the CLI? Message-ID: Hello, I'm trying to send an encrypted email via a cron job. I can't get it to work. For instance, I tried the following command, but it opens up mutt for an interactive session: echo "encrypted msg" | gpg -e --armor -f | \ mutt -s "PGP test" \ -e "my_hdr MIME-Version: 1.0" \ -e "my_hdr Content-Type: application/pgp-encrypted" \ -e "my_hdr Content-Disposition: inline" me at example.com Also tried the following: echo "encrypted msg" | gpg -e --armor -f | \ mutt -s "PGP test" \ -e "my_hdr MIME-Version: 1.0" \ -e "my_hdr Content-Type: multipart/encrypted; protocol='application/pgp-encrypted'" \ -e "my_hdr Content-Disposition: inline" me at example.com And I get the error: Error in command line: protocol=application/pgp-encrypted: unknown command Is there a way to accomplish this (ideally, without creating temporary files for the encrypted part)? -- W. D. Sadeep PGP: 103BF9E3E750BF7E From nunojsilva at ist.utl.pt Sun Oct 19 10:25:12 2025 From: nunojsilva at ist.utl.pt (Nuno Silva) Date: Sun, 19 Oct 2025 11:25:12 +0100 Subject: How to send a PGP-encrypted email from the CLI? References: Message-ID: <10d2ea8$rh1$2@ciao.gmane.io> On 2025-10-19, W. D. Sadeep wrote: > Hello, > > I'm trying to send an encrypted email via a cron job. I can't get it to > work. For instance, I tried the following command, but it opens up mutt > for an interactive session: > > echo "encrypted msg" | gpg -e --armor -f | \ > mutt -s "PGP test" \ > -e "my_hdr MIME-Version: 1.0" \ > -e "my_hdr Content-Type: application/pgp-encrypted" \ > -e "my_hdr Content-Disposition: inline" me at example.com > > Also tried the following: > > echo "encrypted msg" | gpg -e --armor -f | \ > mutt -s "PGP test" \ > -e "my_hdr MIME-Version: 1.0" \ > -e "my_hdr Content-Type: multipart/encrypted; protocol='application/pgp-encrypted'" \ > -e "my_hdr Content-Disposition: inline" me at example.com > > And I get the error: Error in command line: > protocol=application/pgp-encrypted: unknown command > > Is there a way to accomplish this (ideally, without creating temporary > files for the encrypted part)? For the second invocation: Any chance that you have to either enclose the Content-Type value in quotes or escape the semicolon there? -- Nuno Silva From ckeader at disroot.org Sun Oct 19 21:46:20 2025 From: ckeader at disroot.org (ckeader) Date: Sun, 19 Oct 2025 22:46:20 +0100 Subject: How to send a PGP-encrypted email from the CLI? In-Reply-To: References: Message-ID: > And I get the error: Error in command line: > protocol=application/pgp-encrypted: unknown command > > Is there a way to accomplish this (ideally, without creating temporary > files for the encrypted part)? This is an intriguingly simple question, and I thought I had an answer, but it seems this is not currently possible. All methods I came across involve encrypting the message and then piping it into mutt. Not surprisingly, the question has been asked here multiple times. This message, "https://marc.info/?l=mutt-users&m=113222153115670&w=2", says: | ... As I was told here in the list, the command line code | doesn't allow encryption. And I'm wondering why that is. It should be possible especially since modern versions of gnupg use gpg-agent, and when mutt is built with the gpgme interface.