* : Recipient address. * * [--backup] * : Test the backup server instead of the main connection. * * @when after_wp_load */ public function test( $args, $assoc ) { $to = isset( $args[0] ) ? sanitize_email( $args[0] ) : ''; if ( ! is_email( $to ) ) { WP_CLI::error( 'Give a valid recipient address.' ); } $res = LuxMail_Tester::send( $to, ! empty( $assoc['backup'] ) ? 'backup' : 'primary' ); if ( $res['ok'] ) { WP_CLI::success( $res['title'] ); return; } WP_CLI::log( $res['raw'] ); foreach ( $res['tips'] as $tip ) { WP_CLI::log( '- ' . $tip ); } WP_CLI::error( $res['title'] ); } /** * Work with the sending queue. * * ## OPTIONS * * * : run | status * * @when after_wp_load */ public function queue( $args, $assoc ) { $action = isset( $args[0] ) ? $args[0] : 'status'; if ( 'run' === $action ) { $s = LuxMail_Queue::process( true ); WP_CLI::success( sprintf( 'Sent %d, retrying %d, failed %d.', $s['sent'], $s['retrying'], $s['failed'] ) ); return; } $q = LuxMail_Queue::counts(); WP_CLI::log( $q['pending'] . ' waiting' . ( $q['next_at'] ? ', next at ' . $q['next_at'] . ' UTC' : '' ) ); } }