Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def send_mail(to_address, subject, body, extra_images=None, attachments=[], use_celery=USE_CELERY_FOR_EMAIL):
- """
- TODO: Document this
- """
- images = [('signature-translucent.png', 'signature'), ]
- # redirect emails if necessary
- if USER_EMAIL_REDIRECT:
- subject = '%s (redirected from %s )' % (subject, to_address)
- to_address = USER_EMAIL_REDIRECT
- if extra_images:
- images += extra_images
- try:
- if use_celery:
- send_email_task.delay(to_address, subject, body, images, attachments=attachments, APP_ROOT=APP_ROOT)
- else:
- send_email_thread = Thread(target=send_email, args=[to_address, subject, body, images],
- kwargs={'attachments': attachments, 'APP_ROOT': APP_ROOT})
- send_email_thread.start()
- except Exception as e:
- logger.exception("Fatal exception while sending email.\n" + str(e))
- return False
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement