def send_failed(self, request, queryset): emails = queryset.filter(sent=False) for email in emails: if getattr(settings, 'MAILQUEUE_CELERY', defaults.MAILQUEUE_CELERY): from mailqueue.tasks import send_mail send_mail.delay(email) else: email.send() self.message_user(request, "Emails queued.")
def send_mail(self): """ Public api to send mail. Makes the determinination of using celery or not and then calls the appropriate methods. """ if getattr(settings, 'MAILQUEUE_CELERY', defaults.MAILQUEUE_CELERY): from mailqueue.tasks import send_mail send_mail.delay(self.pk) else: self._send()
def send_post_save(sender, instance, signal, *args, **kwargs): if getattr(instance, "do_not_send", False): instance.do_not_send = False return if getattr(settings, 'MAILQUEUE_CELERY', defaults.MAILQUEUE_CELERY): from mailqueue.tasks import send_mail send_mail.delay(instance.pk) else: instance.send()