Add generic send_email task in wagtailadmin.tasks

This will be used from the send form data to email. It has been added to
the wagtailadmin.tasks module to use celery if it has been defined and
configured or just send the email if not (just like the
send_notification task).
pull/173/merge
Serafeim Papastefanos 2014-03-21 23:44:44 +02:00
rodzic 92563ff535
commit b6aca526da
1 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -85,3 +85,16 @@ def send_notification(page_revision_id, notification, excluded_user_id):
# Send email
send_mail(email_subject, email_content, from_email, email_addresses)
@task
def send_email_task(email_subject, email_content, from_email, email_addresses):
if not from_email:
if hasattr(settings, 'WAGTAILADMIN_NOTIFICATION_FROM_EMAIL'):
from_email = settings.WAGTAILADMIN_NOTIFICATION_FROM_EMAIL
elif hasattr(settings, 'DEFAULT_FROM_EMAIL'):
from_email = settings.DEFAULT_FROM_EMAIL
else:
from_email = 'webmaster@localhost'
send_mail(email_subject, email_content, from_email, email_addresses)