Skip to content

For developers

The module redirects WooCommerce emails to the Action Scheduler queue using the woocommerce_mail_callback filter:

add_filter( 'woocommerce_mail_callback', function() {
return [ $this, 'add_job_to_queue' ];
} );
  1. Email capture - The module captures the wp_mail() call
  2. Save to queue - Parameters are saved to wp_options
  3. Schedule action - Action Scheduler schedules immediate sending
  4. Asynchronous sending - Cron triggers the sending
// Action triggered when sending email
do_action( 'wpify_send_email', $hash );

You can monitor the email queue in Tools → Scheduled Actions:

  • Action: wpify_send_email
  • Status: Pending / Complete / Failed
// Parameters are saved as an option with a hash key
$args = [ $to, $subject, $message, $headers, $attachments ];
$hash = md5( json_encode( $args ) );
update_option( $hash, $args );
// When sending
$args = get_option( $hash );
delete_option( $hash ); // After successful loading
add_action( 'wpify_send_email', function( $hash ) {
$args = get_option( $hash );
if ( $args ) {
error_log( sprintf(
'Sending email to: %s, Subject: %s',
$args[0], // to
$args[1] // subject
) );
}
}, 5 ); // Priority before module
add_action( 'wpify_send_email', function( $hash ) {
$args = get_option( $hash );
if ( ! $args ) {
return;
}
// Custom logic before sending
list( $to, $subject, $message, $headers, $attachments ) = $args;
// For example, logging to a custom table
global $wpdb;
$wpdb->insert(
$wpdb->prefix . 'email_log',
[
'to_email' => $to,
'subject' => $subject,
'sent_at' => current_time( 'mysql' ),
]
);
}, 5 );

If you use DISABLE_WP_CRON, set up an external cron:

Terminal window
# Every minute
* * * * * wget -q -O - https://example.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

Or using WP-CLI:

Terminal window
* * * * * cd /path/to/wordpress && wp cron event run --due-now > /dev/null 2>&1

The module uses Action Scheduler (part of WooCommerce), which is more reliable than standard WP Cron:

FeatureWP CronAction Scheduler
TriggeringOn page visitOn visit + CLI
LoggingNoYes
ManagementLimitedFull
ScalabilityLowHigh