I have a client requirement to encrypt all outgoing email from a linux server. This can be done using any software, sendmail/postfix etc. They have given me the key they want to use, and want all forms (using php) to be encrpyted. Can I set sendmail/etc to encrypt all emails? This could be done with the same key for all mail.


  • Do you mean encrypt or sign? Encrypting emails usually means having the public key of the recipients... Otherwise, how are the recipients be able to decrypt the messages? – chmeee May 14 '10 at 10:30
  • chmeee: Where did you see anyone mentioning asymmetric encryption? AliGibbs: What kind of key/encryption are we talking about? Are Web-form-submissions the only thing which need to be encrypted, or are there other mails as well? – andol May 14 '10 at 10:40
  • Chmeee: Sorry- I mean encrypt, using the public key of the recipents. Andol: I thought about using something like GPG, it is only web form submissions (into our content management system). However from a time prospective, it would be easier (I hope) to encrpyt all mails than change other code. – AliGibbs May 14 '10 at 11:06

If you want to encrypt your outgoing mail using GnuPG, without involving your PHP code, then GNU Anubis might be what you are looking for. It can sit in-front of your SMTP server and (among other things) apply GnuPG encryption to your mails.

The potential issue here is that Anubis both accepts and submits mail using SMTP. While there obviously isn't any problem with using SMTP to pass the mails along to Postfix, PHP tend to use the local sendmail binary. One possible solution, which I haven't tried myself, is to point PHP:s sendmail_path= toward the Anubis helper script msg2smtp.pl

Of course, if there's multiple Postfixes involved, one on your web server as well as one on your companies designated mail server, then there really isn't any problem. In that case all you have to do is simply plug Anubis in between.


If by encrypt you mean that all mail should be sent with SSL/TLS, with postfix then you can simply set smtp_enforce_tls to yes. You can tweak the SSL/TLS settings, check all the smtp_tls_* options.

If you want to encrypt the mail with pgp/gpg/smime, then you probably have to write a filter for that and specify it with content_filter.

  • 1
    In modern version of Postfix (2.3+) smtp_tls_security_level= is preferred over smtp_enforce_tls=. – andol May 14 '10 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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