obtain Message instance after email send
Opened this issue · 0 comments
eLRuLL commented
I am implementing a Notifications feature and I'd like to connect the notification with the email sent, for that I included something like the following to my Notification model.
email_message = models.OneToOneField(
djmail_models.Message,
on_delete=models.SET_NULL,
null=True,
blank=True,
verbose_name=_("Email message"),
)
But I don't know how to later match this, the only thing that I was able to come up with was:
self.email_message = djmail_models.Message.objects.filter(
body_html__icontains=self.id
).first()
But that is not optimal, is there a way to get the uuid or model instance for example when the email is sent? or how should I go about doing this? I send the email this way:
email_builder = template_mail.MagicMailBuilder()
context = {
...
}
email = email_builder.notification(self.recipient, context)
email.send() # <---------- it would be cool to have something like "djmail_message = email.send()"