diff options
author | jelle van der Waa <jelle@archlinux.org> | 2019-10-25 21:50:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-25 21:50:52 +0200 |
commit | 1ba5231e5b2af3036a43dc10f8597584a34510fa (patch) | |
tree | 61a4d5771ac993b21a04aed33d11b612d005ce62 | |
parent | c292bdd05d9205c3b1123a6c7f1a91dde7c0ebfd (diff) | |
parent | d3a927e4e0d8257f35f3e45e59ca9161ce0760f6 (diff) | |
download | archweb-1ba5231e5b2af3036a43dc10f8597584a34510fa.tar.gz archweb-1ba5231e5b2af3036a43dc10f8597584a34510fa.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
-rw-r--r-- | news/views.py | 16 | ||||
-rw-r--r-- | settings.py | 3 |
2 files changed, 13 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) diff --git a/settings.py b/settings.py index e91b5aa6..3201f218 100644 --- a/settings.py +++ b/settings.py @@ -178,6 +178,9 @@ COUNTRIES_OVERRIDE = { # Make this unique, and don't share it with anybody. SECRET_KEY = '00000000000000000000000000000000000000000000000' +# Mailman poster password for announcements +MAILMAN_PASSWORD = '' + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', |