I want to mail a simple HTML file containing some data. I want the user to receive rendered HTML. I’ve tried this solution:
b = render_to_string('mail_body.html',{'name':request.POST['name']})
send_mail(email_subject,b,'sender@gmail.com', ['receiver@gmail.com'],
fail_silently=False)
but I don’t get rendered HTML in the mail body and the user can see all of the HTML tags!
Alternatively, when I use the following code I just get the path of my HTML file in the mail body:
params = {}
params['name'] = request.POST['name']
context = Context(params)
t = Template('mail_body.html')
send_mail(email_subject,t.render(context), 'sender@gmail.com',
['receiver@gmail.com'], fail_silently=False)
You could try something like this:
Hope this leads into the right direction. Just note that there are a lot of variables in here which come from my own programming.