django-newsletter icon indicating copy to clipboard operation
django-newsletter copied to clipboard

Per-subscriber per-submission delivery status

Open dokterbob opened this issue 7 years ago • 2 comments

As suggested in #137 and #210, it would be really great to allow for handling of email delivery notifications.

It would probably be ideal to have a structure that is generic enough to allow both status reports from delivery services as well as catching per-message exceptions from the mail delivery agent (they are currently just logged, see https://github.com/dokterbob/django-newsletter/blob/master/newsletter/models.py#L644).

Ideally, we would use/soft-depend on an external package that provides a standard Django email interface but abstracts status notification of different SMTP providers (SES, Sendgrid, Postmark, ...). Then, we could extend the admin to display aggregate and detailed statistics per subscription and per submission.

I guess django-anymail could do this, see #213.

TODO: Confirm whether django-anymail can in fact do this, in which case only the integration of reporting data and setting headers would need to be done.

dokterbob avatar Nov 11 '17 12:11 dokterbob

Turns out django-anymail does not include persistent storage of delivery statusses, but does provide signals and normalized status codes.

Hence, we would have to create something like a DeliveryStatusEvent model, providing a transactional store of status events, relating a Subscription to a Submission, having a date and a status. However, this should be an optional field as this is potentially a lot of data. Apart from the status, there's also a reject_reason field and we would want to store the raw esp_event data for more in-depth feedback.

Statuses: Anymail normalizes ESP sent status to one of these values:

  • 'sent' the ESP has sent the message (though it may or may not end up delivered)
  • 'queued' the ESP has accepted the message and will try to send it asynchronously
  • 'invalid' the ESP considers the sender or recipient email invalid
  • 'rejected' the recipient is on an ESP blacklist (unsubscribe, previous bounces, etc.)
  • 'failed' the attempt to send failed for some other reason
  • 'unknown' anything else

dokterbob avatar Nov 11 '17 12:11 dokterbob

is there any update on this?

kodeine avatar Sep 02 '19 15:09 kodeine