Changed BaseEmail to accept from_address to modify the from header accordingly

This commit is contained in:
M.Ravi 2017-06-07 11:35:16 +05:30
parent a44f64e8e7
commit a60ef7cf7a
2 changed files with 10 additions and 1 deletions

View file

@ -133,6 +133,7 @@ class OrderView(TemplateView):
}
email_data = {
'subject': 'New Order Received',
'from_address': '(datacenterlight) datacenterlight Support <support@datacenterlight.ch>',
'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 <support@datacenterlight.ch>',
'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 <support@datacenterlight.ch>',
'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 <support@datacenterlight.ch>',
'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 <support@datacenterlight.ch>',
'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 <support@datacenterlight.ch>',
'to': 'info@ungleich.ch',
'context': context,
'template_name': 'request_access_notification',

View file

@ -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 <info@ungleich.ch>'
if 'from_address' in kwargs:
self.email.from_email = kwargs.get('from_address')
else:
self.email.from_email = '(ungleich) ungleich Support <info@ungleich.ch>'
self.email.to = [kwargs.get('to', 'info@ungleich.com')]
def send(self):