Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8811437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:21:54+00:00 2026-06-14T03:21:54+00:00

I am sending emails using a template, but the template is not being properly

  • 0

I am sending emails using a template, but the template is not being properly rendered. It shows the html tags and doesn’t render special chars.

It does render the context, for example if I supply it with a “username”:some_name then it will properly display the username when I do {{username}}

my_template.html:

<p>hello &oslash;</p>

In views:

from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.template import Context

t = get_template('my_template.html')
msg = EmailMultiAlternatives("hi", t.render(Context({})), from_email, [user.email])
msg.send()

The received email shows up with the p tags displayed. Also, the entity appears exactly as written in the template. I’d be fine just using a .txt file except that I need the special chars to be rendered. If I write them directly in the txt file, I get an error when trying to send it.

I have also tried using django’s send_mail(). Also adding an html tag to the template. Same result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:21:55+00:00Added an answer on June 14, 2026 at 3:21 am

    a multipart/alternative email has two parts:

    1. a plain text version of the email
    2. an html version of the email

    so here you just gotta do #2 and add the html part!

    following the example here… https://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-types …you’d probably just have to add a line like this before msg.send()`

    msg.attach_alternative(t.render(Context({})), "text/html")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sending test mail using ActionMailer. The template is being rendered and mail is
i m using phpmailer class for sending emails. i m geeting error Could not
before few days i have been comfortably sending emails using PHP mail function. but
Has anyone ever tried sending emails using 1&1 smtp host? I tried the following?
The convention with using JavaMail seems to be: -- Use smtp for sending emails
I am using a script that is sending out emails and I am receiving
I'm sending an email using javascript. It will be sent via outlook but I
I have send an email using php mailer class. mail was sending successfully but
I'm trying to accomplish the following, I'm sending a HTML email using PHP Mailer
I am sending emails using PHP Pear class, when I see mails in gmail,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.