1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from django.core.mail.backends.smtp import EmailBackend
from django.conf import settings
import dkim # http://hewgill.com/pydkim
class DKIMBackend(EmailBackend):
def _send(self, email_message):
"""A helper method that does the actual sending + DKIM signing."""
if not email_message.recipients():
return False
try:
message_string = email_message.message().as_string()
signature = dkim.sign(message_string,
settings.DKIM_SELECTOR,
settings.DKIM_DOMAIN,
settings.DKIM_PRIVATE_KEY)
self.connection.sendmail(email_message.from_email,
email_message.recipients(),
signature+message_string)
except:
if not self.fail_silently:
raise
return False
return True
|
More like this
- DRY Fieldsets by DrMeers 4 years ago
- SSL / HTTPS Middleware for Redirection and href Rewriting by DrMeers 3 years, 1 month ago
- Command to dump data as a python script by willhardy 4 years, 12 months ago
- OpenID Form Field by jpwatts 5 years, 4 months ago
- Mobilize your Django site by stevena0 4 years, 2 months ago
Comments
Do you know how this will work with other backends aside from SMTP?
#
DJango version that supports Email_Backend is 1.2 Any idea how to make this work on 1.1?
best!
#