Coder Social home page Coder Social logo

activecampaign / postmark-wordpress Goto Github PK

View Code? Open in Web Editor NEW
18.0 14.0 17.0 447 KB

The Official Postmark Wordpress Plugin

License: GNU General Public License v2.0

PHP 87.73% CSS 2.49% JavaScript 9.78%
postmark postmark-integrations email mail wordpress

postmark-wordpress's Introduction

Postmark Logo

ActiveCampaign Postmark for WordPress

If you’re still sending email with default SMTP, you’re blind to delivery problems! ActiveCampaign Postmark for WordPress enables sites of any size to deliver and track WordPress notification emails reliably, with minimal setup time and zero maintenance.

If you don’t already have an ActiveCampaign Postmark account, you can get one in minutes, sign up at https://postmarkapp.com.

Installation

  1. Upload postmark directory to your /wp-content/plugins directory or install from plugin marketplace
  2. Activate plugin in WordPress admin
  3. In WordPress admin, go to Settings then ActiveCampaign Postmark. You will then want to insert your ActiveCampaign Postmark details. If you don’t already have an ActiveCampaign Postmark account, get one at https://postmarkapp.com.
  4. Verify sending by entering a recipient email address you have access to and pressing the “Send Test Email” button. Enable logging for troubleshooting and to check the send result.
  5. Once everything is verified as working, check Send emails using ActiveCampaign Postmark and Save, to override wp_mail to send using the ActiveCampaign Postmark API instead.

FAQ

What is ActiveCampaign Postmark?

ActiveCampaign Postmark is a hosted service that expertly handles all delivery of transactional webapp and web site email. This includes welcome emails, password resets, comment notifications, and more. If you've ever installed WordPress and had issues with PHP's mail function not working right, or your WordPress install sends comment notifications or password resets to spam, ActiveCampaign Postmark makes all of these problems vanish in seconds. Without ActiveCampaign Postmark, you may not even know you're having delivery problems. Find out in seconds by installing and configuring this plugin.

Will this plugin work with my WordPress site?

The ActiveCampaign Postmark for WordPress plugin overrides any usage of the wp_mail function. Because of this, if any 3rd party code or plugins send mail directly using the PHP mail function, or any other method, we cannot override it. Please contact the makers of any offending plugins and let them know that they should use wp_mail instead of unsupported mailing functions.

TLS Version Requirements/Compatibility

The ActiveCampaign Postmark API requires TLS v1.1 or v1.2 support. We recommend using TLS v1.2.

You can check your TLS v1.2 compatibility using this plugin. After installing the plugin, change the dropdown for 'Select API Endpoint' to How's My SSL? and run the test. If compatibility with TLS v1.2 is not detected, contact your server host or make the necessary upgrades to support TLS v1.1 or v1.2.

TLS 1.2 requires:

  • PHP 5.5.19 or higher
  • cURL 7.34.0 or higher
  • OpenSSL 1.0.1 or higher

Does this cost me money?

The ActiveCampaign Postmark service (and this plugin) are free to get started, for up to 100 emails a month. You can sign up at https://postmarkapp.com/. When you need to process more than 100 emails a month, ActiveCampaign Postmark offers monthly plans to fit your needs.

My emails are still not sending, or they are going to spam! HELP!?

First, enable logging in Settings and check your send attempts for any errors returned by the ActiveCampaign Postmark API. These errors can let you know why the send attempts are failing. If you aren't seeing log entries for your send attempts, then the plugin or contact form generating the emails is likely not using wp_mail and not compatible with this plugin.

If you are still unsure how to proceed, just send an email to [email protected] or tweet @postmarkapp for help. Be sure to include as much detail as possible.

Why should I trust you with my email sending?

Because we've been in this business for many years. We’ve been running an email marketing service, Newsberry, for five years. Through trial and error we already know what it takes to manage a large volume of email. We handle things like whitelisting, ISP throttling, reverse DNS, feedback loops, content scanning, and delivery monitoring to ensure your emails get to the inbox.

Most importantly, a great product requires great support and even better education. Our team is spread out across six time zones to offer fast support on everything from using ActiveCampaign Postmark to best practices on content and user engagement. A solid infrastructure only goes so far, that’s why improving our customer’s sending practices helps achieve incredible results.

How do I tag a message?

There are two ways to tag a message.

  1. Set an X-PM-Tag message header, i.e. array_push( $headers, 'X-PM-Tag: PostmarkPluginTest' ); where you are calling wp_mail().

  2. Add a filter for postmark_tag that hooks into a function that returns the tag you desire.

Using the postmark_tag filter option will override a tag set via message headers.

Why aren't my HTML emails being sent?

This plugin detects HTML by checking the headers sent by other WordPress plugins. If a "text/html" content type isn't set then this plugin won't send the HTML to ActiveCampaign Postmark to be sent out only the plain text version of the email.

Why are password reset links not showing in emails sent with this plugin?

There are a couple ways to resolve this issue.

  1. Open the ActiveCampaign Postmark plugin settings and uncheck Force HTML and click Save Changes. If the default WordPress password reset email is sent in Plain Text format, the link will render as expected.

  2. Access your WordPress site directory and open the wp-login.php file.

Change this line:

$message .= ‘<‘ . network_site_url(“wp-login.php?action=rp&key=$key&login=” . rawurlencode($user_login), ‘login’) . “>\r\n”;

Remove the brackets, so it becomes:

$message .= network_site_url(“wp-login.php?action=rp&key=$key&login=” . rawurlencode($user_login), ‘login’) . “\r\n”;

And save the changes to the file.

How do I set the from name?

The plugin supports using the wp_mail_from_name filter for manually setting a name in the From header.

Additional Resources

ActiveCampaign Postmark for WordPress FAQ

Can I use the ActiveCampaign Postmark for WordPress plugin with Gravity Forms?

How do I send with Ninja Forms and ActiveCampaign Postmark for WordPress?

How do I send with Contact Form 7 and ActiveCampaign Postmark for WordPress?

Can I use the ActiveCampaign Postmark for WordPress plugin with Divi contact forms?

Changelog

[1.19.1]

  • Fix warning when logging sends with a null To address

See the previous changelogs here

ActiveCampaign, 2022

postmark-wordpress's People

Contributors

andrewhaines avatar atheken avatar bhubbard avatar chexwarrior avatar cklosowski avatar ethanclevenger91 avatar ewood-ac avatar guillaumemolter avatar jptoto avatar mgibbs189 avatar multisuperfreek avatar pgraham3 avatar renatonascalves avatar robertocorreale avatar tflight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postmark-wordpress's Issues

wp_mail_from* filters are ignored

It looks like only the From headers are used to override whatever is set in postmark_settings, and that wp_mail_from and wp_mail_from_name are ignored. Is this correct?

This would suggest that we need to append to a From header in some way when we are using Postmark with a plugin that adds filters for wp_mail_from and from_name.

Does this sound about right?

Make "Test Send" error more obvious.

When doing a test send, we currently dump the API response to the UI. This is to allow customers that face issues an easy way to provide us data about their issue if they contact us in support. However, the var_dump is pretty ugly, and not very friendly to most users.

Let's improve the "error experience" for Test Sends.

Apply pre_wp_mail filter to wp_mail() override

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 a pre_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/honor pre_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!

Graceful timeout handeling

A customer of ours got alerted by customers of his shop, that they weren't allways receiving their digital products. After some digging I found this in the plugin logs:

cURL error 28: Operation timed out after 5000 milliseconds with 0 out of -1 bytes received

Since I use Postmark (and by extend this plugin) for the reliable delivery, this is no good. I was hoping this plugin would do better than the regular SMTP service, and maybe retry or use a (way) longer timeout, so that delivery can be (better) garanteed.

Tag Default WordPress and WooCommerce Emails

I would love it if we could have all the default emails get Postmark Tag Support. So for example the New User Email could get a tag like 'wp-new-user' or something similar to that. Here is a good list I found of all the default WordPress emails.

https://github.com/johnbillion/wp_mail

Being able to filter these emails by tags in Postmark would be extremely useful.

Expose errors using `postmark_error` filter.

Since the wp_mail function returns void, it is harder to expose API exceptions to plugins and client code.

Make the plugin expose errors when postmark_error filters are supplied.

Why is Force HTML / Track Opens deprecated?

I'm curious as to why this is deprecated?

There's lots of cases where the user doesn't have direct control of wp_mail such as when emails are sent via other plugins (think form plugins).

Can we remove the deprecated notice?

Add option to setup settings on wp-config file

Hi,
I would like to request this feature.
There are many advantages for this, some of them are:

  • Secure your API KEY data. The admin dashboard can be accessed for many users, and sometimes you do not want that data to be leaked to your developers, clients or the SEO guy.
  • It allow to easily deploy websites with your plugin using scripts. No need to go into the UI at all.
  • It prevents clients or other admins to delete the API key by mistake, affecting the delivery of the emails, which is something critical on any website, as you know. :)
  • It allows to use the POSTMARK_API_TEST key programmatically with no need to add extra functionality to the plugin for that. This was part requested on #10
  • Following up that, this will be really useful to add this into staging sites that are generated by scripts, so email won´t be send by mistake when testing upgrades (a common thing in WordPress).
  • It will facilitate to convert this plugin into a Must Use plugin, as requested on #5 (and #3)
  • It will also help to make this work with a multisite installation in the future, as settings can be used for all installations by default. #11 and #15
  • It will make sense if you decide to complete #33 and add wp cli support, because you can ignore the UI completely.

So, I think it is clearly something not that complicated that will bring a lot of benefits to everyone.
I hope you can consider this.
Best regards and thank you for the great service and support you provide!

1.10.1 PHP error

After upgrading to the new 1.10.1 version and going to Settings -> Postmark in wp-admin, the following error appears in PHP error logs:

WordPress database error Table 'ts.wp_postmark_log' doesn't exist for query SELECT COUNT(*) FROM wp_postmark_log made by require_once('C:\inetpub\TS\wwwroot\wp-admin\admin.php'), do_action('settings_page_pm_admin'), WP_Hook->do_action, WP_Hook->apply_filters, Postmark_Mail->settings_html, include('C:\inetpub\TS\wwwroot\wp-content\plugins\postmark-approved-wordpress-plugin\page-settings.php')

Looks like it's trying to load the new log table, but it's not created on upgrade.

This happens every time I load the settings page.

Setup Gulp

I suggest setting up Gulp, to do the following:

  • Compile and Minify the CSS & JS for the plugin
  • Optimize Images within the plugin
  • To make a github markdown version of the readme file.
  • etc

Plugin not working - because it is overwritting the wp_mail() function

The Postmark plugin overwrites the native WordPress wp_mail() function. Tthis is a bad practice. You should use the wp_mail filter instead, and use unique names for your functions.

The Postmark plugin now relies on loading the modified wp_mail function before the official WordPress function wp_mail is loaded.

This solution works OK, but only if some other plugin does not require the official WordPress wp_mail() function before...

But plugins do this sometimes. For Example the Redux Framework plugin, which a lot of theme autors use for their Theme Options. In order to load Redux extension like the Demo import Redux extension, they require pluggable.php file (The file where WP core function wp_mail is defined).
Example code:
require_once ABSPATH . '/wp-includes/pluggable.php';

This causes the wp_mail function to be registered before it would normally be and before the Postmark plugin overwrites the wp_mail function with its own version.

And in this case, the Postmark is not loaded at all:

if ( ! function_exists( 'wp_mail' ) ) {
  $postmark = new Postmark_Mail();
    ...
  }
}

If you would use the wp_mail filter instead of overwriting the wp_mail function, you would still get access to all the WordPress mail data, but without the need for overwriting the WordPress functions. Your custom wp_mail function should be restructured as separate function with unique naming.

I know fixing this issue requires a lot of refactoring, but it will solve many potential issues.

Call to undefined function mime_content_type() in wp-mail.php line 163

Some systems don't have the mime.magic module enabled, or are running versions of PHP without support for the function mime_content_type(). This results in the above fatal error.

The solution is rather simple. Please add this to your plugin:

if ( ! function_exists( 'mime_content_type' ) ) {

function mime_content_type( $filename ) {
    $finfo = finfo_open( FILEINFO_MIME_TYPE );
    $mime_type = finfo_file( $finfo, $filename );
    finfo_close( $finfo );
    return $mime_type;
}

}

WP-CLI Support

I would like to see support for WP-CLI. There could be useful commands such as sending a test email, etc.

Show error message if plugin cannot be enabled

After a good 30+ minutes, we finally found the FAQ item stating that the plugin is not shown if another plugin is using wp_mail. Would it instead be possible to still show the menu item with a message stating why it's not enabled/being used?

Disable REST API email sending programatically

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!

Propagate headers to Postmark API

Currently, only "recognized" headers are assigned to message properties when sending a message. The non-recognized headers are silently ignored by the plugin, but should be passed to the API when sending the message.

Allow "From" header to override the default sender.

Allow users to include a "From" header in mail they send using the wp_mail function. This would override the default sender configured in the control panel. (The sender would still need to be a confirmed sender signature...)

Wordpress Error on Upgrade to v1.13.0

Happens on multiple sites

Notice: Undefined variable: postmark in /app/wp-content/plugins/postmark-approved-wordpress-plugin/postmark.php on line 457
Fatal error: Uncaught Error: Call to a member function load_settings() on null in /app/wp-content/plugins/postmark-approved-wordpress-plugin/postmark.php:457

Admin then gets an email saying a terminal error existed.

Option and filter for sending test emails using POSTMARK_API_TEST key

From #6 via @atheken:

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

I'd love to see this added as an option (to toggle in plugin settings) and filter (to toggle programmatically). If I can view the emails within the Postmark dashboard without them getting actually sent, then this would
alleviate the need to use Mailtrap or similar services for my staging site email testing.

Improve handling of errors when Postmark API is timing out

https://wordpress.org/support/topic/curl-timeout-at-postmark-causes-woocommerce-errors/

On May 28, Postmark’s API was down for about a half-hour
https://status.postmarkapp.com/incidents/105834

In the DB log table, we see errors such as this:
cURL Error 28: Operation timed out after 30001 milliseconds

In a WooCommerce flow, this had the unfortunate impact of users orders succeeding to be placed, but then erroring out on trying to send. Which caused them not to get to the thank you page, nor receive any confirmation.

Is this something addressable via the plugin? i.e. can it defer sends to not be in the direct flow? or handle this error case better?

Add links to WordPress related Postmark help articles to ReadMe

  • Postmark for WordPress FAQ
  • Can I use the Postmark for WordPress plugin with Gravity Forms?
  • How do I send with Ninja Forms and Postmark for WordPress?
  • How do I send with Contact Form 7 and Postmark for WordPress?
  • Can I use the Postmark for WordPress plugin with Divi contact forms?

Environment based settings

b2bdd wrote:

I think it would be great to be able to have different settings for different environments (local/staging/production), OR be able to override the plugin settings using a definition in the wp-config.php file. Please see https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-function-in-wordpress-5-5/ for info about the recently added wp function to get the environment type constant.

I often have to copy production sites to a local environment to work on them and if they have postmark installed it can lead to weird emails being sent to clients. I'd like to be able to just have a custom definition to send all emails to myself on development environments.

Topic Link: https://wordpress.org/support/topic/feature-request-support-for-environment-types-override-in-wp-config/

Potentially related to #69

Rest API

It would be great to have rest api endpoints for each of the webhooks needed in Postmark. This could allow the site to handle the actions as it sees best.

Many notices related to the constants being already defined.

It doesn't affect the functionality, but it appears there is possibly a path that leads two instances of the main Postmark_Mail to be instantiated, and because the __construct is setting some constants, it is possible for the notices to be dropped into the debug log.

A simple step for now would just be to throw in a "! defined()check on each constant before usingdefine`. This at least prevents the plugin from trying to redefine constants and reduces the footprint on the logs.

PR Incoming as well for you.

Test Email Notice

When you send a test email, the notice is persistent until you leave the page. There should be an option to remove it.

GitHub vs WP.org

MAJOR ISSUE:
I just tried to contribute to the codebase by checking out the repo here on GitHub.
When I activated tagged version 1.11.2 (gh) in my dev install it took me some time to realize that the version is broken.
The code differs from the released version on wp.org!
e.g. link tracking can not be activated because the js file is missing the code to hand the setting over to the ajax request.

Please update the repo with the current release code.
I am ready to put my work, time and energy into this project and my money in the service. If the plugin can not close the gap to the fantastic service/webUI I need to move on to a rival service.

E_ERROR from file class-postmark-debug.php

In version 1.17.0 (latest) a couple customers reported issues with the new Site Health addition. Reverted stable to v1.16.1 for now until we fix it.

Error

An error of type E_ERROR was caused in line 99 of the file /home/utag/public_html/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php. Error message: Uncaught TypeError: Postmark_Debug::strbool(): Argument #1 ($value) must be of type bool, null given, called in /home/utag/public_html/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php on line 64 and defined in /home/utag/public_html/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php:99
Stack trace:
#0 /home/utag/public_html/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php(64): Postmark_Debug->strbool()
#1 /home/utag/public_html/wp-includes/class-wp-hook.php(307): Postmark_Debug->debug_info()
#2 /home/utag/public_html/wp-includes/plugin.php(191): WP_Hook->apply_filters()
#3 /home/utag/public_html/wp-admin/includes/class-wp-debug-data.php(1461): apply_filters()
#4 /home/utag/public_html/wp-admin/site-health-info.php(32): WP_Debug_Data::debug_data()
#5 /home/utag/public_html/wp-admin/includes/class-wp-site-health.php(66): require_once(‘/home/utag/publ…’)
#6 /home/utag/public_html/wp-includes/class-wp-hook.php(307): WP_Site_Health->show_site_health_tab()
#7 /home/utag/public_html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#8 /home/utag/public_html/wp-includes/plugin.php(476): WP_Hook->do_action()
#9 /home/utag/public_html/wp-admin/site-health.php(205): do_action()
#10 {main}
thrown

https://wordpress.org/support/topic/1-17-0-update-throw-a-wp-error-notification/#post-15752616

https://wordpress.org/support/topic/an-error-of-type-e_error-was-caused-in-line-99-of-the-file/#post-15750328

Postmark not pruning old log entries

Hello,

Bit of an edge-case for ya. I recently had a run-in with a plugin where it was attempting to send up to 100 emails every minute non-stop for the past few weeks. I've notified the plugin developers of how this situation arose, and hopefully it doesn't happen again, but it has led to some unintended side-effects. To put it simply, the other plugin I had an issue with led to over 1.15 million failed send attempts to a single address over the last few weeks.

Postmark's cron event to prune log entries older than 7 days, pm_log_cron_job, runs once per day. I've attempted to run this cron event manually numerous times, and it's not pruning anything. I've got log entries nearly a month old. I think its not doing anything because its attempting to delete over 800,000 rows from the database in a single transaction, and I assume that's exceeding a limit set somewhere in our infrastructure. Might be worth pruning in chunks if the number of rows to delete is excessively high.

This was on a site running latest version of WordPress, latest version of Postmark plugin. Problem plugin was Events Manager / Events Manager Pro. I wrote about my findings to the developers here.

Please let me know if you need anything else from me.

Thanks!
Brad

Allow configurable timeout for DNS lookups.

Investigate options for allowing longer DNS lookup windows.

From user report:

"I looked at the result of the $response request in postmark.../wp-mail.php and got this error:

wp-error - http request error - name lookup timed out.

It appears my dns was a bit slow. So I looked up the docs of the wp_remote_post function and added a timeout option to the $args array and that fixed it."

Don't store settings as JSON

update_option accepts arrays as parameter and will handle auto-serialization.

get_option will also auto-deserialize into an array.

I know JSON is great and pretty popular but WordPress uses PHP serialized data. Not using it requires some extra processing that would normally be automatically handled by WordPress. It also breaks compatibility with some widely use WordPress tools (ie: search-replace of the WP-CLI).

POSTMARK_DIR is undefined when upgrading plugin via CLI

https://wordpress.org/support/topic/upgrade_completed-method-uses-undefined-postmark_dir-constant/

If you upgrade any other plugin via the CLI (wp plugin upgrade), you get a warning from Postmark that POSTMARK_DIR is undefined, as it’s called via a filter, and isn’t initialized.

Can this be addressed?

Warning: Use of undefined constant POSTMARK_DIR – assumed ‘POSTMARK_DIR’ (this will throw an Error in a future version of PHP) in /app/wp-content/plugins/postmark-approved-wordpress-plugin/postmark.php on line 450

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.