Baobab icon indicating copy to clipboard operation
Baobab copied to clipboard

Add email logging/tracking

Open avishkar58 opened this issue 4 years ago • 1 comments

We currently have an intermittent issue where some people don't receive emails from Baobab and there doesn't appear to be a pattern to this (ie other people in the same domain receive the emails etc). In order to get to the bottom of this, we need to add more logging of emails and integrate some of the monitoring features available in Amazon's Simple Email Service. In particular:

  • Create a new Message model with fields:
    • user_id (int, references app_user.id)
    • template_id (int, references email_template.id)
    • address (string) (the user's email address)
    • method (string) (this should always be "email" for now, until we introduce other message routes like SMS)
    • subject (string)
    • message (string)
    • status (string)
    • status_message (string)
    • timestamp (datetime)

Update the email user function in emailer.py to add a new entry to the Message table for each message that gets sent. Update the status to "Sent" if the email is sent to Amazon SES successfully, or to "Failed" if the email fails to send (include the error in status_message if this is the case)

Create a service that subscribes to Amazon's Simple Notification Service for our email bounces and delivery notifications. When a notification is received, update the status of the relevant email to either "Bounced" or "Delivered" with any appropriate status_message that might be included in the notification.

NOTE: This still requires a bit of research to make sure that we capture enough information to join the entry in our table to the relevant notification from Amazon.

avishkar58 avatar Dec 11 '20 13:12 avishkar58

Hi @avishkar58 I could also claim this? Looks interesting.

bdhobare avatar Aug 27 '21 23:08 bdhobare