Answers:
尝试像
gpg -ea -r "Recipient name" -o - filename | mail -s "Subject line" recipient@example.com
通过电子邮件指定收件人行,将文件“文件名”的经过ascii防护的,用公钥加密的副本发送给名为“收件人名”的人(您的gpg密钥环中的人),电子邮件地址为receive@example.com。
要么
echo "Your secret message" | gpg -ea -r "Recipient name" | mail -s "Subject" recipient@example.com
直接发送文本,而不是从磁盘上的明文文件发送文本。
这是我写的一个小脚本。将其保存到〜/ username / bin / gpgmail并运行chmod 755 gpgmail
。使用运行gpgmail
。
#!/bin/bash
# Send encrypted email
# Requires gpg and mail to be setup
echo "Available keys:"
gpg --list-keys
# Gather variables
echo "Enter public key of recipient:"
read user
echo "Enter email:"
read email
echo "Enter subject:"
read subject
echo "Enter message:"
read message
# Pipe the echoed message to gpg, sign and encrypt it to ascii (-eas), include your key so you can read it,
# include recipients key, pipe to mail with the (unencrypted) subject, send to the given email.
echo "$message" | gpg2 --no-emit-version -eas -r galenasphaug@gmail.com -r $user | mail -s "$subject" $email