Allow to add multiple Bcc addresses

This commit is contained in:
Raphael Michel
2019-05-14 10:18:09 +02:00
parent 2c7cefea35
commit 6ef3603d9f
2 changed files with 15 additions and 5 deletions

View File

@@ -111,7 +111,8 @@ def mail(email: str, subject: str, template: Union[str, LazyI18nString],
if event: if event:
renderer = event.get_html_mail_renderer() renderer = event.get_html_mail_renderer()
if event.settings.mail_bcc: if event.settings.mail_bcc:
bcc.append(event.settings.mail_bcc) for bcc_mail in event.settings.mail_bcc.split(','):
bcc.append(bcc_mail.strip())
if event.settings.mail_from == settings.DEFAULT_FROM_EMAIL and event.settings.contact_mail and not headers.get('Reply-To'): if event.settings.mail_from == settings.DEFAULT_FROM_EMAIL and event.settings.contact_mail and not headers.get('Reply-To'):
headers['Reply-To'] = event.settings.contact_mail headers['Reply-To'] = event.settings.contact_mail

View File

@@ -2,7 +2,7 @@ from django import forms
from django.conf import settings from django.conf import settings
from django.contrib.auth.hashers import check_password from django.contrib.auth.hashers import check_password
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator from django.core.validators import RegexValidator, validate_email
from django.db.models import Q from django.db.models import Q
from django.forms import formset_factory from django.forms import formset_factory
from django.utils.html import escape from django.utils.html import escape
@@ -781,6 +781,13 @@ class InvoiceSettingsForm(SettingsForm):
self.fields['invoice_language'].choices = [('__user__', _('The user\'s language'))] + [(a, locale_names[a]) for a in event.settings.locales] self.fields['invoice_language'].choices = [('__user__', _('The user\'s language'))] + [(a, locale_names[a]) for a in event.settings.locales]
def multimail_validate(val):
s = val.split(',')
for part in s:
validate_email(part.strip())
return s
class MailSettingsForm(SettingsForm): class MailSettingsForm(SettingsForm):
mail_prefix = forms.CharField( mail_prefix = forms.CharField(
label=_("Subject prefix"), label=_("Subject prefix"),
@@ -790,12 +797,14 @@ class MailSettingsForm(SettingsForm):
) )
mail_from = forms.EmailField( mail_from = forms.EmailField(
label=_("Sender address"), label=_("Sender address"),
help_text=_("Sender address for outgoing emails") help_text=_("Sender address for outgoing emails"),
) )
mail_bcc = forms.EmailField( mail_bcc = forms.CharField(
label=_("Bcc address"), label=_("Bcc address"),
help_text=_("All emails will be sent to this address as a Bcc copy"), help_text=_("All emails will be sent to this address as a Bcc copy"),
required=False validators=[multimail_validate],
required=False,
max_length=255
) )
mail_text_signature = I18nFormField( mail_text_signature = I18nFormField(