Merge pull request #316 from pcoder/bug/3328/dcl_email_headers

Changed BaseEmail to accept from_address to modify the from header ac…
This commit is contained in:
Levi Velázquez 2017-06-11 12:30:29 -05:00 committed by GitHub
commit 2f0b38302a
2 changed files with 14 additions and 4 deletions

View file

@ -130,9 +130,11 @@ class OrderView(TemplateView):
}
email_data = {
'subject': "Data Center Light Order from %s" % context['email'],
'to': ['info@ungleich.ch'],
'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]),
'reply_to': [context['email']],
'from_address': '(datacenterlight) datacenterlight Support <support@datacenterlight.ch>',
'to': 'info@ungleich.ch',
'context': context,
'template_name': 'new_order_notification',
'template_path': 'datacenterlight/emails/'
}
email = EmailMessage(**email_data)
email.send()
@ -153,6 +155,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',
@ -167,6 +170,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',
@ -217,6 +221,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',
@ -319,6 +324,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',
@ -333,6 +339,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,6 +21,9 @@ class BaseEmail(object):
self.email = EmailMultiAlternatives(self.subject, text_content)
self.email.attach_alternative(html_content, "text/html")
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')]