1

Hi I want to send an email with the order confirmation in html5 / bootstrap format but the email I receive has no style.

I am attaching the html template that is written with html5 and bootstrap3 tags.

The view is :

plaintext = get_template('shopcart/email_compra.txt')// I dont think this is necessary
htmly     = get_template('shopcart/email.html')
customer_data = userData.objects.get(user=o.customer)
d = Context({ 'username': user, 'cart': cart, 'order':o, 'customer':customer_data })
subject = 'Your order'
text_content = plaintext.render(d) // I dont think this is necessary
html_content = htmly.render(d)
msg = EmailMultiAlternatives(subject, text_content, from_email, [user.email])
msg.attach_alternative(html_content, "text/html")
msg.send()

The email is sent with the html content but no format ( this is causing for example to have missing columns of the order ) Thanks

Ismail Badawi
  • 36,054
  • 7
  • 85
  • 97
jesicadev18
  • 2,942
  • 5
  • 22
  • 39

1 Answers1

1

It's Simple when you are rendering your html try to give full path for your static files.

Like if you want to access bootstrap in my emails use full path. In my case i have saved http://localhost:8000 in a context variable called site and rendering in the template like below.

<link rel="stylesheet" type="text/css" href="{{site}}{% static 'css/bootstrap.css' %}">

It will serve all static files including css, js and images.

binu.py
  • 1,137
  • 2
  • 9
  • 20