Need to manually re-send 'waiting-send' emails

While sending emails using e-newsletter , we found that many emails stay as "waiting-send" and are then never send.
Is there any way to send the 'waiting-send' emails? Please note, we are not sending them using cron. Are there any hooks we use to re-send them?

  • Ivan

    Hi peter !

    You can create {wordpress_folder}/wp-content/mu-plugins/wpmu_send_waiting_emails.php file via FTP with the following code

    <?php
    function wpmu_send_waiting_emails() {
      	global $email_newsletter, $wpdb;
    	$flag = get_transient( 'wpmu_send_waiting_emails_temp' );
    
    	if ( empty( $email_newsletter ) || $flag)
    		return;
    
    	set_transient( 'wpmu_send_waiting_emails_temp', true );
    
    	$items = $wpdb->get_col( "SELECT send_id FROM {$email_newsletter->tb_prefix}enewsletter_send_members WHERE status = 'waiting_send'");
    	foreach ( $items as $send_id ) {
    		$message = $email_newsletter->send_email_to_member( $send_id );
    		if ( 'ok'  !==  $message && is_admin() ) {
    			var_dump( $message );
    			delete_transient( 'wpmu_send_waiting_emails_temp' );
    			exit;
    		}
    	}
    	delete_transient( 'wpmu_send_waiting_emails_temp' );
    }
    
    add_action( 'plugins_loaded', 'wpmu_send_waiting_emails' );

    After that, you should go to the admin area of the main site ( or subsite or just in the admin area for a single site) and you will see error why these emails did not send or you won't see the error and all emails will be sent. Then delete this code. Also, you can delete these lines if you want not see any error in the admin area during re-sending these emails.

    if ( 'ok'  !==  $message && is_admin() ) {
        var_dump( $message );
        delete_transient( 'wpmu_send_waiting_emails_temp' );
        exit;
    }

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.