benecaster_resend_email()
benecaster_resend_email( int $log_id ): int|WP_Error
Sends one logged email again, exactly as it went out: the same subject, body, sender and headers, to the address the queue stored, from the copy the queue kept. Nothing is re-rendered. Use it when a listener says an account or billing email never arrived.
The resend is queued as a one-off, the email log gains a queued row for it, and benecaster_email_resent fires. benecaster_after_email_send does not.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
log_id |
int |
— | Yes | The id of a row from benecaster_get_email_log(). |
Return Value
Type:
int|WP_Error
The new email queue row id, or a WP_Error saying why nothing was sent. The error's data carries an HTTP status.
Example
if ( current_user_can( 'manage_options' ) ) {
$result = benecaster_resend_email( $log_id );
if ( is_wp_error( $result ) ) {
echo esc_html( $result->get_error_message() );
}
}
Hooks Fired
Notes
Only some emails can be resent. Anything else returns a WP_Error, nothing is sent, and the code says why:
- benecaster_resend_not_found (404) — no log row with that id.
- benecaster_resend_wrong_type (409) — only a transactional type (see benecaster_is_transactional_email_type()) or one registered 'unsubscribable' => false can be resent. A broadcast or an episode notification is sent again from its own screen.
- benecaster_resend_wrong_status (409) — the log row must be sent or failed.
- benecaster_resend_past_retention (409) — older than benecaster_get_email_log_retention_days().
- benecaster_resend_no_stored_copy (409) — no stored copy of the email is left.
- benecaster_resend_opted_out (409) — the recipient has since unsubscribed in a way that stops this email.
- benecaster_resend_queue_failed (500) — the queue write failed; try again.
It is the same text. A sign-in link that has expired, or a feed URL that has been reset since, goes out as it was. The benecaster_email_should_send filter is not asked again; only Benecaster's own opt-outs are.
There is no capability check, and it sends mail. Check manage_options, or your own capability, first. See Resend an email from the log.
Need this built rather than just documented? See our services →