From e3de35fa15f3268086a4cc0ceeb04eb4c452d646 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Thu, 15 Aug 2013 19:09:10 +0200 Subject: [PATCH] No need for a sendmail compatible smtp anymore. --- dpaste/settings_local.example.py | 2 +- dpaste/smtp.py | 57 -------------------------------- dpaste/urls/dpaste.py | 2 ++ 3 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 dpaste/smtp.py diff --git a/dpaste/settings_local.example.py b/dpaste/settings_local.example.py index f5a2855..6c2c3ad 100644 --- a/dpaste/settings_local.example.py +++ b/dpaste/settings_local.example.py @@ -19,4 +19,4 @@ DATABASES = { SECRET_KEY = 'changeme' -EMAIL_BACKEND = 'dpaste.smtp.EmailBackend' +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/dpaste/smtp.py b/dpaste/smtp.py deleted file mode 100644 index 2dbfcea..0000000 --- a/dpaste/smtp.py +++ /dev/null @@ -1,57 +0,0 @@ -"""sendmail email backend class.""" - -import threading - -from django.core.mail.backends.base import BaseEmailBackend -from subprocess import Popen, PIPE - - -class EmailBackend(BaseEmailBackend): - """ - EmailBackend that uses a local 'sendmail' binary instead of a local - SMTP daemon. - """ - def __init__(self, fail_silently=False, **kwargs): - super(EmailBackend, self).__init__(fail_silently=fail_silently) - self._lock = threading.RLock() - - def open(self): - return True - - def close(self): - pass - - def send_messages(self, email_messages): - """ - Sends one or more EmailMessage objects and returns the number of email - messages sent. - """ - if not email_messages: - return - self._lock.acquire() - try: - num_sent = 0 - for message in email_messages: - sent = self._send(message) - if sent: - num_sent += 1 - finally: - self._lock.release() - return num_sent - - def _send(self, email_message): - """A helper method that does the actual sending.""" - if not email_message.recipients(): - return False - try: - ps = Popen(["sendmail"]+list(email_message.recipients()), \ - stdin=PIPE) - ps.stdin.write(email_message.message().as_string()) - ps.stdin.flush() - ps.stdin.close() - return not ps.wait() - except: - if not self.fail_silently: - raise - return False - return True diff --git a/dpaste/urls/dpaste.py b/dpaste/urls/dpaste.py index 13f4dcd..b9ae171 100644 --- a/dpaste/urls/dpaste.py +++ b/dpaste/urls/dpaste.py @@ -1,5 +1,7 @@ from django.conf.urls.defaults import url, patterns +from . import views + urlpatterns = patterns('dpaste.views', url(r'^$', 'snippet_new', name='snippet_new'), url(r'^guess/$', 'guess_lexer', name='snippet_guess_lexer'),