Sendmail plugin: Allow to attach a file to emails (#1814)

* sendmail: allow to attach files to emails

* Fix mixup of model objects and model IDs

* Attach to order-level emails, not only position-level emails

* Give attachments a proper file type

* Add a warning note about higher spam chances

Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
Sohalt
2020-10-22 09:53:19 +02:00
committed by GitHub
parent d673a43130
commit 9e4dc344a4
5 changed files with 51 additions and 18 deletions

View File

@@ -10,7 +10,8 @@ from pretix.celery_app import app
@app.task(base=ProfiledEventTask, acks_late=True)
def send_mails(event: Event, user: int, subject: dict, message: dict, orders: list, items: list,
recipients: str, filter_checkins: bool, not_checked_in: bool, checkin_lists: list) -> None:
recipients: str, filter_checkins: bool, not_checked_in: bool, checkin_lists: list,
attachments: list = None) -> None:
failures = []
user = User.objects.get(pk=user) if user else None
orders = Order.objects.filter(pk__in=orders, event=event)
@@ -61,7 +62,8 @@ def send_mails(event: Event, user: int, subject: dict, message: dict, orders: li
event,
locale=o.locale,
order=o,
position=p
position=p,
attach_cached_files=attachments
)
o.log_action(
'pretix.plugins.sendmail.order.email.sent.attendee',
@@ -87,7 +89,8 @@ def send_mails(event: Event, user: int, subject: dict, message: dict, orders: li
email_context,
event,
locale=o.locale,
order=o
order=o,
attach_cached_files=attachments
)
o.log_action(
'pretix.plugins.sendmail.order.email.sent',