Unverified Commit 1ba5231e authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by GitHub
Browse files

Merge pull request #252 from grazzolini/arch_announce_password

news: Add the MAILMAN_PASSWORD option and use it for sending authenticated emails
parents c292bdd0 d3a927e4
from django import forms 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.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.template import loader from django.template import loader
...@@ -43,12 +44,15 @@ def form_valid(self, form): ...@@ -43,12 +44,15 @@ def form_valid(self, form):
ctx = { ctx = {
'news': newsitem, 'news': newsitem,
} }
headers = dict()
if settings.MAILMAN_PASSWORD:
headers['Approved'] = settings.MAILMAN_PASSWORD
template = loader.get_template('news/news_email_notification.txt') template = loader.get_template('news/news_email_notification.txt')
send_mail('[arch-announce] %s' % newsitem.title, EmailMessage(subject='[arch-announce] %s' % newsitem.title,
template.render(ctx), body=template.render(ctx),
'"Arch Linux: Recent news updates: %s" <arch-announce@archlinux.org>' % newsitem.author.get_full_name(), from_email='"Arch Linux: Recent news updates: %s" <arch-announce@archlinux.org>' % newsitem.author.get_full_name(),
['arch-announce@archlinux.org'], to=['arch-announce@archlinux.org'],
fail_silently=True) headers=headers).send()
return super(NewsCreateView, self).form_valid(form) return super(NewsCreateView, self).form_valid(form)
......
...@@ -178,6 +178,9 @@ ...@@ -178,6 +178,9 @@
# Make this unique, and don't share it with anybody. # Make this unique, and don't share it with anybody.
SECRET_KEY = '00000000000000000000000000000000000000000000000' SECRET_KEY = '00000000000000000000000000000000000000000000000'
# Mailman poster password for announcements
MAILMAN_PASSWORD = ''
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment