Decrypt GPG encrypted email

It took me awhile to figure out how to extract PDF attachment from an encrypted email message received with Gmail. I think that is because the attachments were encrypted in a bundle with the message and not separately. Maybe mig5 can confirm. If the attachments were encrypted separately that could probably work better as I could simply run gpg -o att.tar -d att.tar.gpg for each attachment.

Download the original message from Gmail, save it as .asc file, remove all the email headers (everything before BEGIN PGP MESSAGE and also everything after END PGP MESSAGE) and decrypt with gpg msg.asc. GPG will write a file with the same name and no extension.

Make two copies of the file cp msg{,.txt} - one for extracting the attachment and the other to keep the message in. Now the attachment is encoded with base64 in msg file. To extract it remove everything but base64 gibberish from inside the file and run base64 -d msg > msg.pdf