Settings', 'Log', 'Queue', 'FAQs', ); return array_merge($actions,$links ); } add_filter('plugin_action_links_mail-queue/mail-queue.php','wdm_wpma_actionlinks'); // Options Page function wdm_wpma_settings_page_menuitem() { add_menu_page('Mail Queue','Mail Queue','manage_options','wdm_wpma_mail_queue','wdm_wpma_settings_page','data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTc4IiBoZWlnaHQ9IjE3OCIgdmlld0JveD0iMCAwIDE3OCAxNzgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNzguNzI0MSA1LjI1MzA5Qzc2LjkwNzQgNC43MDgxIDc0Ljk0MDEgNS4wNTQxMyA3My40MTg0IDYuMTg2MjlDNzEuODk2OCA3LjMxODQ1IDcxIDkuMTAzNDEgNzEgMTEuMDAwMVYxNjdDNzEgMTY4Ljg5NyA3MS44OTY4IDE3MC42ODIgNzMuNDE4NCAxNzEuODE0Qzc0Ljk0MDEgMTcyLjk0NiA3Ni45MDc0IDE3My4yOTIgNzguNzI0MSAxNzIuNzQ3TDE1OC43MjQgMTQ4Ljc0N0MxNjEuMjYyIDE0Ny45ODYgMTYzIDE0NS42NSAxNjMgMTQzVjM1QzE2MyAzMi4zNTA0IDE2MS4yNjIgMzAuMDE0NSAxNTguNzI0IDI5LjI1MzFMNzguNzI0MSA1LjI1MzA5Wk04NS43ODg3IDIyLjM4NDZDODcuNzg1NCAyMS40Mzk0IDkwLjE3MDMgMjIuMjkxOSA5MS4xMTU0IDI0LjI4ODdMMTIyLjg1MiA5MS4zMzc4TDE0My4zMzQgNDQuNDAwMkMxNDQuMjE3IDQyLjM3NTUgMTQ2LjU3NSA0MS40NTAzIDE0OC42IDQyLjMzMzhDMTUwLjYyNSA0My4yMTc0IDE1MS41NSA0NS41NzUgMTUwLjY2NiA0Ny41OTk4TDEyNi42NjYgMTAyLjZDMTI2LjAzOSAxMDQuMDM3IDEyNC42MjkgMTA0Ljk3NiAxMjMuMDYxIDEwNUMxMjEuNDkzIDEwNS4wMjQgMTIwLjA1NiAxMDQuMTI5IDExOS4zODUgMTAyLjcxMUw4My44ODQ2IDI3LjcxMTNDODIuOTM5NCAyNS43MTQ2IDgzLjc5MTkgMjMuMzI5NyA4NS43ODg3IDIyLjM4NDZaIiBmaWxsPSIjYTdhYWFkIi8+CjxwYXRoIGQ9Ik00OSAxM0M1Mi4zMTM3IDEzIDU1IDE1LjY4NjMgNTUgMTlWMTU5QzU1IDE2Mi4zMTQgNTIuMzEzNyAxNjUgNDkgMTY1QzQ1LjY4NjMgMTY1IDQzIDE2Mi4zMTQgNDMgMTU5VjE5QzQzIDE1LjY4NjMgNDUuNjg2MyAxMyA0OSAxM1oiIGZpbGw9IiNhN2FhYWQiLz4KPHBhdGggZD0iTTIxIDIxQzI0LjMxMzcgMjEgMjcgMjMuNjg2MyAyNyAyN1YxNTFDMjcgMTU0LjMxNCAyNC4zMTM3IDE1NyAyMSAxNTdDMTcuNjg2MyAxNTcgMTUgMTU0LjMxNCAxNSAxNTFWMjdDMTUgMjMuNjg2MyAxNy42ODYzIDIxIDIxIDIxWiIgZmlsbD0iI2E3YWFhZCIvPgo8L3N2Zz4='); add_submenu_page('wdm_wpma_mail_queue','Settings','Settings','manage_options','wdm_wpma_mail_queue','wdm_wpma_settings_page'); add_submenu_page('wdm_wpma_mail_queue','Log','Log','manage_options','wdm_wpma_mail_queue-tab-log','wdm_wpma_settings_page'); add_submenu_page('wdm_wpma_mail_queue','Queue','Queue','manage_options','wdm_wpma_mail_queue-tab-queue','wdm_wpma_settings_page'); add_submenu_page('wdm_wpma_mail_queue','FAQ','FAQ','manage_options','wdm_wpma_mail_queue-tab-faq','wdm_wpma_settings_page'); if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) { add_submenu_page('wdm_wpma_mail_queue','Cron Information','Cron Information','manage_options','wdm_wpma_mail_queue-tab-croninfo','wdm_wpma_settings_page'); } } add_action('admin_menu','wdm_wpma_settings_page_menuitem'); function wdm_wpma_settings_page_assets () { $screen = get_current_screen(); if ( preg_match( '#wdm_wpma_mail_queue#', $screen->base ) ) { wp_enqueue_style( 'wdm_wpma_style', plugins_url( 'assets/css/admin.css', __FILE__ ) ); wp_enqueue_script( 'wdm_wpma_script', plugins_url( 'assets/js/wdm-wpma-admin.js', __FILE__ ), [ 'jquery' ], false, true ); } } add_action( 'admin_enqueue_scripts', 'wdm_wpma_settings_page_assets' ); // Options Page Settings function wdm_wpma_settings_page() { // Only Admins if ( ! current_user_can( 'manage_options' ) ) { return; } // Settings global $wdm_wpma_options; // Get the active tab from the $_GET param $default_tab = null; $tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : $default_tab; echo '
Please note:
Your normal WP Cron is disabled. Please make sure you\'re running the Cron manually by calling '.$url.' every couple of minutes.
Next Sending will be triggered in '.esc_html(human_time_diff($next_cron_timestamp)).' at '.esc_html(wp_date('H:i',$next_cron_timestamp)).'.
The Queue is not enabled at the moment. Enable it in the Settings.
If enabled this plugin intercepts the wp_mail() function. Instead of sending the mails directly, it stores them in the database and sends them step by step with a delay during the WP Cron.
'; echo 'Current state: '; if ($wdm_wpma_options['enabled'] == '1') { echo 'The plugin is enabled All Mails sent through wp_mail() are delayed by the Queue.'; } else { echo 'The plugin is disabled. The plugin has no impact at the moment, no Mails inside the Queue are going to be sent.'; } echo '
'; echo 'No, don\'t worry. This plugin only affects WHEN emails are sent, not how. It delays the sending (by the Queue), nonetheless all emails are sent through the standard wp_mail() function.
'; echo 'If you use SMTP for sending, or an external service like Mailgun, everything will still work as expected.
'; echo 'If you\'re using a Caching plugin like W3 Total Cache, WP Rocket or any other caching solution which generates static html-files and serves them to visitors, you\'ll have to make sure you\'re calling the wp-cron file manually every couple of minutes.
'; echo 'Otherwise your normal WP Cron wouldn\'t be called as often as it should be and scheduled messages would be sent with big delays.
'; echo 'Same situation here. Please make sure you\'re calling the WordPress Cron by an external service or your webhoster every couple of minutes.
'; echo 'You are covered. All attachments are stored temporarily in the queue until they are sent along with their corresponding emails.
'; echo 'This is a simple and effective way to improve the security of your WordPress installation.
Imagine: In case your website is sending spam through wp_mail(), the email Queue would fill up very quickly preventing your website from sending so many spam emails at once. This gives you time and avoids a lot of trouble.
Queue Alerts warn you, if the Queue is longer than usal. You decide at which point you want to be alerted. So you get the chance to have a look if there might be something wrong on the website.
'; echo 'Current state: '; if ($wdm_wpma_options['alert_enabled'] == '1') { echo 'Alerts are enabled If more than '.esc_html($wdm_wpma_options['email_amount']).' emails are waiting in the Queue, WordPress will sent an alert email to '.esc_html($wdm_wpma_options['email']).'.'; } else { echo 'Alerting is disabled. No alerts will be sent.'; } echo '
'; echo 'Please note: This plugin will only send one alert every six hours.
'; echo 'Yes, you can add the custom `X-Mail-Queue-Prio` header set to `High` to your email. High priority emails will be sent through the standard Mail Queue sending cycle but before all normal emails lacking a priority header in the queue.
'; echo 'Example 1 (add priority to Woocommerce emails):
'; echo 'add_filter(\'woocommerce_mail_callback_params\',function ( $array ) {
$prio_header = \'X-Mail-Queue-Prio: High\';
$array[3] .= $prio_header."\\r\\n";
return $array;
},10,1);';
echo 'Example 2 (add priority to a Contact Form 7 form email):
'; echo 'When editing a form in Contact Form 7 just add an additional line to the `Additional Headers` field under the `Mail` tab panel.
'; echo 'X-Mail-Queue-Prio: High';
echo 'Yes, this is possible (if you absolutely need to do this).
'; echo 'For this you can add the custom `X-Mail-Queue-Prio` header set to `Instant` to your email. These emails are sent instantly circumventing the mail queue. They still appear in the Mail Queue log flagged as `instant`.
'; echo 'Mind that this is a potential security risk and should be considered carefully. Please use only as an exception.
'; echo 'Example 1 (instantly send Woocommerce emails):
'; echo 'add_filter(\'woocommerce_mail_callback_params\',function ( $array ) {
$prio_header = \'X-Mail-Queue-Prio: Instant\';
$array[3] .= $prio_header."\\r\\n";
return $array;
},10,1);';
echo 'Example 2 (instantly send a Contact Form 7 form email):
'; echo 'When editing a form in Contact Form 7 just add an additional line to the `Additional Headers` field under the `Mail` tab panel.
'; echo 'X-Mail-Queue-Prio: Instant';
echo 'Sure! Put a Test Email for '.esc_html($wdm_wpma_options['email']).' into the Queue
'; echo 'It look\'s like you deactived the WP Cron by define( \' DISABLE_WP_CRON \' , true ).
'; $url = esc_url(get_option('siteurl').'/wp-cron.php'); echo 'In general, this is no problem at all. We just want to remind you to make sure you\'re running the Cron manually by calling '.$url.' every couple of minutes.
'; echo 'The Queue wasn\'t been able to be executed since '.esc_html(human_time_diff($tasks_of_mailqueue_in_past,time())).'.
'; } echo 'Sorry, your email to '.$maildata->recipient.' can\'t be sent again.
'; $notice .= 'The email used to have attachments, which are not available anymore. Only emails without attachments can be resend.
'; $notice .= 'The other emails have been put again into the Queue.
'; $notice .= 'This is an important message from your Mail Queue plugin. Please take a look at your Mail Log. The last email(s) couldn\'t be sent properly.
'; $notice .= 'Last error message was: '.$last_mail['info'].'
'; $notice .= 'Please contact your Administrator. It seems that WordPress is not able to send emails.
'; $notice .= 'Last error message: '.$last_mail['info'].'
'; $notice .= '