Closed aytackokus closed 7 years ago
@aytackokus - This is really great. Since I'm not a wordpress guru, I've struggled with how best to provide this feedback, without breaking the wp_mail
convention. This is a really elegant solution to that problem. I think it could also make sense to emit a hook for sending errors. What do you think?
@atheken Thanks. I think adding a hook for sending errors is a nice to have feature.
@atheken do you want me to add it? or will you do it?
@aytackokus If you have time to take a crack at it, I would appreciate it.
@atheken it is done!
Hello @atheken, when will you push this changes to the plugin?
This is an enhancement for the issue #22
This feature will allow us to save MessageID after the email is sent.
If you want to save the MessageID to a POST, then you need to add the post id to the $headers argument of wp_mail function. This will not create any malfunctions with email part, because the headers does get filtered to a new variable ($recognized_headers).
For example:
$headers['post_id'] = $post_id;
Arguments sent with the hook: $response = response from postmarkapp API $headers = headers from wp_mail function
So after the email is sent, we can catch the response_data by adding an action hook.
add_action('postmark_response', 'handle_postmark_response', 10, 2);
function handle_postmark_response($response_data, $headers) {
$response_data = json_decode($response_data['body']);
$post_id = $headers['post_id'];
$message_id = $response_data->MessageID;
}