Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding options to gpg for more control of encryption

  • Loading branch information...
commit 95354a36b00273e0c08a8326214791aa7ca362a7 1 parent 6cadb8d
Diego Andres Sanabria Martin diegueus9 authored
Showing with 7 additions and 3 deletions.
  1. +1 −1  email_extras/settings.py
  2. +6 −2 email_extras/utils.py
2  email_extras/settings.py
View
@@ -4,4 +4,4 @@
GNUPG_HOME = getattr(settings, "EMAIL_EXTRAS_GNUPG_HOME", None)
USE_GNUPG = getattr(settings, "EMAIL_EXTRAS_USE_GNUPG", GNUPG_HOME is not None)
-
+ALWAYS_TRUST = getattr(settings, "EMAIL_EXTRAS_ALWAYS_TRUST", False)
8 email_extras/utils.py
View
@@ -5,7 +5,7 @@
from django.template import loader, Context
from django.core.mail import EmailMultiAlternatives
-from email_extras.settings import USE_GNUPG, GNUPG_HOME
+from email_extras.settings import USE_GNUPG, GNUPG_HOME, ALWAYS_TRUST
if USE_GNUPG:
@@ -47,9 +47,13 @@ def send_mail(subject, body_text, addr_from, addr_to, fail_silently=False,
if valid_key_addresses:
gpg = GPG(gnupghome=GNUPG_HOME)
+ kwargs = {}
+ if ALWAYS_TRUST:
+ kwargs.update({'always_trust':ALWAYS_TRUST})
+
# Encrypts body if recipient has a gpg key installed.
encrypt_if_key = lambda body, addr: (body if addr not in valid_key_addresses
- else unicode(gpg.encrypt(body, addr)))
+ else unicode(gpg.encrypt(body, addr, **kwargs)))
# Load attachments and create name/data tuples.
attachments_parts = []
Please sign in to comment.
Something went wrong with that request. Please try again.