From 39bed0b1172ec0a1e32b42b337b6a1e15ca39f13 Mon Sep 17 00:00:00 2001 From: Zachary McCord Date: Sat, 24 Feb 2018 19:16:00 -0400 Subject: [PATCH 1/2] Accept a SENDMAIL_BINARY setting in case sendmail is not in /usr/sbin --- django_sendmail_backend/backends.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django_sendmail_backend/backends.py b/django_sendmail_backend/backends.py index 87ea195..9fcc74a 100644 --- a/django_sendmail_backend/backends.py +++ b/django_sendmail_backend/backends.py @@ -3,6 +3,7 @@ Credits: https://djangosnippets.org/snippets/1864/ """ +from django.conf import settings from django.core.mail.backends.base import BaseEmailBackend from subprocess import Popen, PIPE @@ -27,11 +28,13 @@ def send_messages(self, email_messages): def _send(self, email_message): """A helper method that does the actual sending.""" recipients = email_message.recipients() + sendmail_binary = getattr(settings, 'SENDMAIL_BINARY', + '/usr/sbin/sendmail') if not recipients: return False try: # -t: Read message for recipients - ps = Popen(['/usr/sbin/sendmail'] + recipients, stdin=PIPE, stderr=PIPE) + ps = Popen([sendmail_binary] + recipients, stdin=PIPE, stderr=PIPE) ps.stdin.write(email_message.message().as_bytes()) (stdout, stderr) = ps.communicate() except: From c3acfe43f15e156bc41f9016e9f1b4d30c3ea49f Mon Sep 17 00:00:00 2001 From: Zachary McCord Date: Thu, 31 May 2018 10:05:22 -0400 Subject: [PATCH 2/2] add blurb on SENDMAIL_BINARY to readme --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b530884..18482f5 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,16 @@ Set the EMAIL_BACKEND var in your settings module EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend' +If your sendmail binary is not at /usr/sbin/sendmail (see MTA section below), +you'll also need to set + + SENDMAIL_BINARY = '/path/to/sendmail' + # MTA -You will need any mta installed (like postfix or exim) and a executable **sendmail** command -in your bin path. +You will need any mta installed (like postfix or exim) and a executable +**sendmail** command. Try to install [msmtp](http://msmtp.sourceforge.net/) for test