Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to make my email encrypted as email is confidential. Can anyone please tell me how to encrypt the email using the mailx command. In my shell script I have already used mailx to send the emails, so I want this to be done by mailx command only. Any suggestions ?

share|improve this question
You can use PGP on the commandline: – SPRBRN Feb 6 '14 at 8:53
Encrypt how...? – Adrian Frühwirth Feb 6 '14 at 9:03
can you please provide me the format for that? whether should I use pgp or gpg ? – Pooja25 Feb 6 '14 at 9:13

1 Answer 1

Here’s how I did it:

  1. Create text file.
  2. Encrypt that text file.
  3. Attach that encrypted text file to an email.

Here is a Bash script that implements the idea:

date > /tmp/gpgtxt.txt

gpg -ea -r /tmp/gpgtxt.txt

cat /tmp/gpgtxt.txt.asc | mailx -s "cli encryption" \
-a /tmp/gpgtxt.txt.asc \
-S smtp-use-starttls \
-S ssl-verify=ignore \
-S smtp-auth=login \
-S smtp=smtp:// \
-S from="" \
-S \
-S smtp-auth-password="senderpassword" \
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.