4👍
✅
So after trying and trying I found a solution that worked for me.
t = loader.get_template('orders/invoice_email.html')
c = {
'order': order,
}
body = u''.join(t.render(Context(c))).encode('utf-8').strip()
email = EmailMessage(subject, body, from_mail, [to, ])
email.encoding = "utf-8"
email.content_subtype = "html"
email.attach_file(invoice.name, mimetype="application/pdf")
email.send()
I hope this will help if someone has the same problem.
Source:stackexchange.com