How do I encrypt outgoing system emails via GPG on ubuntu 14.04?

I’m running a simple HTML website on Ubuntu 14.04 managed by Serverpilot (NGINX). The form on my (forced SSL) website uses a simple PHP mailer to send visitor messages to my external email account. Is there a way to encrypt all form entries via GPG (or PGP) before sending it to my external email account?

P.S.: I don’t mind if your method makes all system mails encrypted by default.


I have a similar question. The article about GPG was tempting, but WHERE TO GET IT? Does anyone know what G P G stands for?

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I was able to locate a couple options for you to do this:

  • An answer here suggests using GNU Anubis to encrypt emails but this may require using SMTP for your sending rather than the php mail() function.
  • The answer to this question demonstrates how to encrypt the content of your message in PHP before sending it using GnuPG.