How can I send HTML email via Celery? It keeps sending in text/plain
I setup a system Django/Celery/Redis. And I used EmailMultiAlternatives to send my HTML and Text email.

When I send email as part of the request process, the email is sent in HTML. All runs well and it wraps around a function. Here's the code:

    def send_email(email, email_context={}, subject_template='', 
        body_html_template='', from_email=settings.DEFAULT_FROM_EMAIL):
        
        # render content
        subject = render_to_string([subject_template], context).replace('\n', ' ')
        body_text = render_to_string([body_html_template], context)
        body_html = render_to_string([body_html_template], context)
        
        # send email
        email = EmailMultiAlternatives(subject, body_text, from_email, [email])
        email.attach_alternative(body_html, 'text/html')
        email.send()

However, when I tried to run it as a Celery Task, like below, it just sent as "text/plain". What could be the problem? Or what can I do to find out more? Any hint or solution are greatly appreciated.

    @task(name='tasks.email_features', ignore_result=True)
    def email_features(user):
        email.send_email(user.email,
            email_context={'user': user},
            subject_template='emails/features_subject.txt',
            body_html_template='emails/features_body.html')


How can I send HTML email via Celery? It keeps sending in text/plain
===

I setup a system Django/Celery/Redis. And I used EmailMultiAlternatives to send my HTML and Text email.

When I send email as part of the request process, the email is sent in HTML. All runs well and it wraps around a function. Here's the code:

    def send_email(email, email_context={}, subject_template='', 
        body_html_template='', from_email=settings.DEFAULT_FROM_EMAIL):
        
        # render content
        subject = render_to_string([subject_template], context).replace('\n', ' ')
        body_text = render_to_string([body_html_template], context)
        body_html = render_to_string([body_html_template], context)
        
        # send email
        email = EmailMultiAlternatives(subject, body_text, from_email, [email])
        email.attach_alternative(body_html, 'text/html')
        email.send()

However, when I tried to run it as a Celery Task, like below, it just sent as "text/plain". What could be the problem? Or what can I do to find out more? Any hint or solution are greatly appreciated.

    @task(name='tasks.email_features', ignore_result=True)
    def email_features(user):
        email.send_email(user.email,
            email_context={'user': user},
            subject_template='emails/features_subject.txt',
            body_html_template='emails/features_body.html')

