Skip to content

Instantly share code, notes, and snippets.

@malcalevak
Forked from cfxd/mailpoet-wp_mail.php
Last active July 9, 2017 06:15
Show Gist options
  • Save malcalevak/5ac02aa144fa1837d55bc8aeea39aeef to your computer and use it in GitHub Desktop.
Save malcalevak/5ac02aa144fa1837d55bc8aeea39aeef to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: MailPoet wp_mail() Enabler
Plugin URI: https://gist.github.com/malcalevak/5ac02aa144fa1837d55bc8aeea39aeef/
Description: Enables the ability to use wp_mail() in the MailPoet plugin. Notes: Requires MailPoet v2.6.14+, which added the mailpoet_pre_config_screen action hook. It also appears this is likely to break after the release of v3. Lastly, the MailPoet code doesn't set $header, which is passed to wp_mail; as a result, you'll need to set your 'Content-type:text/html' in your header some other way (Postman SMTP has a Custom Headers field for this purpose, alternatively, you can do it more universally via the answer here: https://wordpress.stackexchange.com/questions/27856/is-there-a-way-to-send-html-formatted-emails-with-wordpress-wp-mail-function)
Version: 1.0
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
function mailpoet_enable_wpmail(){
if(class_exists('WYSIJA')){
$model_config = WYSIJA::get('config','model');
$model_config->save(array('allow_wpmail' => true));
}
}
add_action('mailpoet_pre_config_screen', 'mailpoet_enable_wpmail');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment