From a60ef7cf7a381683aaeea7bcfcea2542c833f08f Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Wed, 7 Jun 2017 11:35:16 +0530 Subject: [PATCH] Changed BaseEmail to accept from_address to modify the from header accordingly --- datacenterlight/views.py | 6 ++++++ utils/mailer.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index d7b6a3e5..cb680109 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -133,6 +133,7 @@ class OrderView(TemplateView): } email_data = { 'subject': 'New Order Received', + 'from_address': '(datacenterlight) datacenterlight Support ', 'to': 'info@ungleich.ch', 'context': context, 'template_name': 'new_order_notification', @@ -157,6 +158,7 @@ class BetaAccessView(FormView): email_data = { 'subject': 'DatacenterLight Beta Access Request', + 'from_address': '(datacenterlight) datacenterlight Support ', 'to': form.cleaned_data.get('email'), 'context': context, 'template_name': 'request_access_confirmation', @@ -171,6 +173,7 @@ class BetaAccessView(FormView): email_data = { 'subject': 'DatacenterLight Beta Access Request', + 'from_address': '(datacenterlight) datacenterlight Support ', 'to': 'info@ungleich.ch', 'context': context, 'template_name': 'request_access_notification', @@ -221,6 +224,7 @@ class BetaProgramView(CreateView): email_data = { 'subject': 'DatacenterLight Beta Access Request', + 'from_address': '(datacenterlight) datacenterlight Support ', 'to': 'info@ungleich.ch', 'context': context, 'template_name': 'request_beta_access_notification', @@ -260,6 +264,7 @@ class IndexView(CreateView): email_data = { 'subject': 'DatacenterLight Beta Access Request', + 'from_address': '(datacenterlight) datacenterlight Support ', 'to': form.cleaned_data.get('email'), 'context': context, 'template_name': 'request_access_confirmation', @@ -274,6 +279,7 @@ class IndexView(CreateView): email_data = { 'subject': 'DatacenterLight Beta Access Request', + 'from_address': '(datacenterlight) datacenterlight Support ', 'to': 'info@ungleich.ch', 'context': context, 'template_name': 'request_access_notification', diff --git a/utils/mailer.py b/utils/mailer.py index 948cdd68..5dc24b04 100644 --- a/utils/mailer.py +++ b/utils/mailer.py @@ -21,7 +21,10 @@ class BaseEmail(object): self.email = EmailMultiAlternatives(self.subject, text_content) self.email.attach_alternative(html_content, "text/html") - self.email.from_email = '(ungleich) ungleich Support ' + if 'from_address' in kwargs: + self.email.from_email = kwargs.get('from_address') + else: + self.email.from_email = '(ungleich) ungleich Support ' self.email.to = [kwargs.get('to', 'info@ungleich.com')] def send(self):