diff --git a/localsettings.dist.py b/localsettings.dist.py index 7477f5a..c12118d 100644 --- a/localsettings.dist.py +++ b/localsettings.dist.py @@ -23,6 +23,10 @@ EMAIL_HOST_PASSWORD = "mail_password" EMAIL_USE_TLS = False EMAIL_USE_SSL = True +# Email address to send outgoing mail from by default + +DEFAULT_FROM_EMAIL = "noreply@example.com" + # Email addresses of system administrators and managers ADMINS = [ @@ -33,6 +37,10 @@ MANAGERS = ADMINS + [ ('Demo Manager', 'manager@example.com'), ] +# Default addresses to BCC messages to + +DEFAULT_BCC_EMAILS = [] + # S3 Bucket Configuration (add options as documented at https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html) ENABLE_S3_STORAGE = False diff --git a/mail/views.py b/mail/views.py index bc22d95..baaf27c 100644 --- a/mail/views.py +++ b/mail/views.py @@ -2,6 +2,7 @@ from django.views.generic.base import ContextMixin from django.template.loader import render_to_string from django.template.exceptions import TemplateDoesNotExist from django.core.mail import EmailMultiAlternatives +from django.conf import settings from html.parser import HTMLParser @@ -48,7 +49,7 @@ class MailView(ContextMixin): def send(self, subject, recipient, context={}, attachments=[], sender=None, cc=[], bcc=[], text_from_html=False): text = self.render_to_text(text_from_html, **context) - email = EmailMultiAlternatives(subject, text, sender, [recipient], cc=cc, bcc=bcc, attachments=attachments) + email = EmailMultiAlternatives(subject, text, sender, [recipient], cc=cc, bcc=bcc + DEFAULT_BCC_EMAILS attachments=attachments) if html := self.render_to_html(**context): email.attach_alternative(html, "text/html") email.send() \ No newline at end of file