Best way to track message sourced from existing record. #219
-
I think I found a good way to handle this scenario — but wondering if there is a better way. 😃 I have a record representing an invite, I then send an email based on it's existence. I wanted to then update the original record with the message_id returned from the ESP I came up with adding a header to the outgoing message that has a UUID for the invite and then when the I'm thinking this is the easiest, cleanest, way to hand this. Yes, no, maybe, I'm I off base? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
What you're doing should work. Extra headers are sent in the message to the recipient, so don't use this if invite-id needs to be kept private from them. One caution: some ESPs will reject non-standard email headers, so There are three other approaches you might consider. Whether they'd be easier or cleaner will depend on your code and your tastes… First, you can add your own custom attributes to any Python object, so rather than using extra_headers you could just assign A second option is adding the sent message_id to your invite record immediately after sending, right in the code that sends the message, rather than in a separate Finally, a third option is to not bother with the ESP-assigned message_id, and instead have the ESP keep track of your invite-id for you. Anymail's metadata lets you attach custom data to a message to make it available in tracking webhooks. You would set |
Beta Was this translation helpful? Give feedback.
-
based on the test environment , Webhook failed with status code 405 |
Beta Was this translation helpful? Give feedback.
What you're doing should work. Extra headers are sent in the message to the recipient, so don't use this if invite-id needs to be kept private from them. One caution: some ESPs will reject non-standard email headers, so
'invite-id'
could cause an error. Email standards allow all custom headers with anx-
prefix, so'x-invite-id'
would be more reliable.There are three other approaches you might consider. Whether they'd be easier or cleaner will depend on your code and your tastes…
First, you can add your own custom attributes to any Python object, so rather than using extra_headers you could just assign
message.invite_id
before sending, and then read that same attribute in yourpost_send
…