Email Confirmations
- Lets try to see how to use email package to develop an email activation feature on the insta cook platform for user registration as well as email verification
- We already have code/api designed in a way where email addresses are being sent by users.
- We need to ensure the correctness of email address as we would communicate to the user in the future
- User Registration workflow
- Lab Setup:
- Mailgun API Refer Here:
- This is third party SMTP and API sending email provider.
- Through mailgun, as part of free plan we can send 5000 email per month
- This is enough for learning purposes
- Mailgun provides an RESTful API, which will be used to send the emails
- Sign up for the mailgun Refer Here
- After your account is activated, Navigate to sending and select the sandbox
- Make a note of base url and API Key
- Mailgun API Refer Here:
- Lets use mailgun API to send out emails Refer Here
- Refer Here for the implementation of email sending functionality
User Account Activation workflow
- The steps:
- User registers for our application
- send out verification email
- user clicks on the link in the activation email
- Account Activated
- To build this workflow, we will be using is_active attribute in the user model to indicate if the account is validated or not
- We need to create a method to send verification email when the user registers and the endpoint can be used to open the account.
- In order to create a unique link, we will be using
itsdangerous
package - Refer Here for the implementation of generation and verification of token
- Refer Here for the documetation of itsdangerous package