Registry Mirror
Skip to content

Disable REST API email sending programatically #6

Closed

Description

@pderksen

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!

Activity

  1. mgibbs189 commented on Apr 20, 2016

    @mgibbs189
    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' );
  2. mgibbs189 commented on Apr 20, 2016

    @mgibbs189
    Contributor
  3. pderksen commented on Apr 20, 2016

    @pderksen
    Author

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

  4. atheken commented on Apr 28, 2016

    @atheken
    Contributor

    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

  5. pderksen commented on Apr 28, 2016

    @pderksen
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions