Closed JordanPak closed 2 years ago
I'd like to second this. It would be nice if we could short-circuit sending and just log the outbound message attempt. https://developer.wordpress.org/reference/hooks/pre_wp_mail/
Hey @JordanPak @davelozier!
I have a PR opened for this request here. Can you please give it a look/test it out to see if it meets your needs?
Thanks!
Hey @pgraham3 that looks perfect and worked well in a test I just conducted. Thank you so much!
@pgraham3 what Jordan said. I wont be able to test until later this evening but the code changes look to be exactly what is needed.
Awesome - appreciate you two taking a look!
Thanks again @pgraham3! :)
I'm building an "email whitelist" plugin into a site that I'm working on so staging and local development environments can block all outgoing emails unless they're "To" a recipient(s) in a whitelist managed by the plugin. Out out the box, WordPress'
wp_mail()
has apre_wp_mail
filter that I can use to short-circuit the message if all of the "To" recipients have been filtered out BEFORE the site tries to send out the message.The
wp_mail()
override in the Postmark plugin does not apply/check/honorpre_wp_mail
, which means all of my outgoing messages get a "failed" response in the plugin's API log. It'd definitely be better for the site (and I imagine Postmark itself) if those emails with no remaining recipients (because they all weren't on the whitelist) could just be "cancelled" by the plugin before Postmark tries to process it and send it to the API.Thank you for your time!