Linux – How to send gpg encrypted mail automatically from the linux command line

emailgnupglinux

How can I send gpg encrypted mail automatically from the linux command line?

I'm a little stumped on this one, I've tried using mutt but it doesn't encrypt mail unless it's used interactively.

Does anyone know if you can use the build in mail command to do this some how?

Best Answer

try something like

gpg -ea -r "Recipient name" -o - filename | mail -s "Subject line" recipient@example.com

to send an ascii-armored, public-key-encrypted copy of the file "filename" to a person named "Recipient name" (who is in your gpg keyring) at email address recipient@example.com with the specified subject line.

or

echo "Your secret message" | gpg -ea -r "Recipient name" | mail -s "Subject" recipient@example.com

to send text directly rather than from a cleartext file on disk.