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

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?


Solution 1:

try something like

gpg -ea -r "Recipient name" -o - filename | mail -s "Subject line" [email protected]

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 [email protected] with the specified subject line.

or

echo "Your secret message" | gpg -ea -r "Recipient name" | mail -s "Subject" [email protected]

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