Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable REST API email sending programatically #6

Closed
pderksen opened this issue Apr 19, 2016 · 5 comments
Closed

Disable REST API email sending programatically #6

pderksen opened this issue Apr 19, 2016 · 5 comments

Comments

@pderksen
Copy link

Is there a way to disable sending emails via the REST API through code?

In my case, when I make a snapshot of my live site to staging (in this case WP Engine), I can then detect I'm on a staging URL, and send automated emails through the site to a test SMTP server (in this case mailtrap.io).

If I forget this then user accounts on my site will start to get automated emails through the staging site (purchase renewal reminders, etc).

If there was simply a way to disable sending emails with this plugin (like unchecking the "Enable" checkbox in the settings does) without having to deactivate the entire plugin that would be ideal.

Thanks!

@mgibbs189
Copy link
Contributor

Hi @pderksen

Not currently, but we could probably add a filter to this line.

Before:

if ( 1 == $postmark->settings['enabled'] ) {

After:

$enabled = (bool) $postmark->settings['enabled'];
if ( apply_filters( 'postmark_enabled', $enabled ) ) {

Usage:

add_filter( 'postmark_enabled', '__return_true' );

@mgibbs189
Copy link
Contributor

mgibbs189 commented Apr 20, 2016

@atheken see #7

@pderksen
Copy link
Author

@mgibbs189 That should do it. Pretty straight-forward. Thanks!

@atheken
Copy link
Contributor

atheken commented Apr 28, 2016

Thanks @mgibbs189! I merged it to master.

@pderksen Feel free to grab the latest from master, or you might also use our "testing" key for sending from staging, POSTMARK_API_TEST, as outlined here: http://developer.postmarkapp.com/developer-send-api.html

@pderksen
Copy link
Author

@atheken Also would be useful in my case. See follow-up #10. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants