summaryrefslogtreecommitdiffstats
path: root/news/views.py
diff options
context:
space:
mode:
authorjelle van der Waa <jelle@archlinux.org>2019-10-25 21:50:52 +0200
committerGitHub <noreply@github.com>2019-10-25 21:50:52 +0200
commit1ba5231e5b2af3036a43dc10f8597584a34510fa (patch)
tree61a4d5771ac993b21a04aed33d11b612d005ce62 /news/views.py
parentc292bdd05d9205c3b1123a6c7f1a91dde7c0ebfd (diff)
parentd3a927e4e0d8257f35f3e45e59ca9161ce0760f6 (diff)
downloadarchweb-f510969b7ba8a516df7894339a2c1b0c5ea34a40.tar.gz
archweb-f510969b7ba8a516df7894339a2c1b0c5ea34a40.zip
Merge pull request #252 from grazzolini/arch_announce_passwordrelease_2019-10-25
news: Add the MAILMAN_PASSWORD option and use it for sending authenticated emails
Diffstat (limited to 'news/views.py')
-rw-r--r--news/views.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/news/views.py b/news/views.py
index 48295944..24423cca 100644
--- a/news/views.py
+++ b/news/views.py
@@ -1,5 +1,6 @@
from django import forms
-from django.core.mail import send_mail
+from django.conf import settings
+from django.core.mail import EmailMessage
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect
from django.template import loader
@@ -43,12 +44,15 @@ class NewsCreateView(CreateView):
ctx = {
'news': newsitem,
}
+ headers = dict()
+ if settings.MAILMAN_PASSWORD:
+ headers['Approved'] = settings.MAILMAN_PASSWORD
template = loader.get_template('news/news_email_notification.txt')
- send_mail('[arch-announce] %s' % newsitem.title,
- template.render(ctx),
- '"Arch Linux: Recent news updates: %s" <arch-announce@archlinux.org>' % newsitem.author.get_full_name(),
- ['arch-announce@archlinux.org'],
- fail_silently=True)
+ EmailMessage(subject='[arch-announce] %s' % newsitem.title,
+ body=template.render(ctx),
+ from_email='"Arch Linux: Recent news updates: %s" <arch-announce@archlinux.org>' % newsitem.author.get_full_name(),
+ to=['arch-announce@archlinux.org'],
+ headers=headers).send()
return super(NewsCreateView, self).form_valid(form)