Configuring email notifications
This section will help us to build actual email notifications instead of flash messages. We will write our logic to trigger the send email action in the same FormClassView
class where we added messages inside the post()
method. We will be utilizing the Mailtrap account that we created at the beginning of this chapter to capture all emails that are sent by our project. If you have not already done so, please create an account with Mailtrap and configure that connection in your settings.py
file. Without doing so, you will have difficulty executing the code throughout this section.
There are three MIME types that exist for emails, as follows:
- Plain text –
text/plain
- Rich text –
application/rtf
- HTML –
text/html
While there are three MIME types, only two are used by Django when sending emails: plain text and HTML. Rich text emails are treated as HTML emails because they contain HTML markup.