0 ? round( ( $fail / $total ) * 100 ) : 0; if ( $rate < $threshold ) { return; } if ( get_transient( self::TRANSIENT_LAST ) ) { return; } $to = (string) ( $settings['alerts_email'] ?? get_option( 'admin_email' ) ); $site = get_bloginfo( 'name' ); $subj = sprintf( /* translators: %s: site name */ __( '[%s] SMTP failure rate alert', 'ago-mail-pilot' ), $site ); $body = sprintf( /* translators: 1: failure rate, 2: total emails, 3: failures, 4: admin URL */ __( 'Your site %4$s is failing to deliver email. Failure rate in the last %2$d outgoing emails: %1$d%% (%3$d failed). Review the log: %5$s Run the DNS audit: %6$s This alert is throttled to one per 24 hours.', 'ago-mail-pilot' ), $rate, $total, $fail, $site, admin_url( 'admin.php?page=ago-mail-pilot#log' ), admin_url( 'admin.php?page=ago-mail-pilot#dns' ) ); wp_mail( $to, $subj, $body ); set_transient( self::TRANSIENT_LAST, time(), self::THROTTLE_SECS ); } }