File tree 1 file changed +24
-2
lines changed
1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ INSTALLED_APPS = [
17
17
]
18
18
```
19
19
20
- 3 . Use the template tag
20
+ 3 . Use the bootstrap_email template tag in your Django template
21
21
22
22
``` html
23
23
{% load bootstrap_email %}
@@ -28,7 +28,7 @@ INSTALLED_APPS = [
28
28
<div class =" card my-10" >
29
29
<div class =" card-body" >
30
30
<p >
31
- Hello World!
31
+ {{ message }}
32
32
</p >
33
33
</div >
34
34
</div >
@@ -37,6 +37,28 @@ INSTALLED_APPS = [
37
37
{% end_bootstrap_email %}
38
38
```
39
39
40
+ 4 . Create the email and send it
41
+
42
+ ``` python
43
+ context = {
44
+ " message" : " Hello World!" ,
45
+ }
46
+
47
+ subject = " Greeting"
48
+ # you should always include a plain text version of the HTML email
49
+ text_content = render_to_string(" path/to/template.txt" , context)
50
+ html_content = render_to_string(" path/to/template.html" , context)
51
+
52
+ email_message = EmailMultiAlternatives(
53
+ subject = subject,
54
+ body = text_content,
55
+
56
+
57
+ )
58
+ email_message.attach_alternative(html_content, " text/html" )
59
+ email_message.send()
60
+ ```
61
+
40
62
And a complete HTML email will be output, which should render correctly across email clients:
41
63
42
64
![ Rendered HTML email example] ( https://raw.githubusercontent.com/jhthompson/django-bootstrap-email/main/example.png )
You can’t perform that action at this time.
0 commit comments