benecaster_send_email_to_address()
benecaster_send_email_to_address( string $email, string $type, string $subject, string $template, array $context = [] ): int
Sends one Benecaster email of a registered type to an address with no account on the site, and returns the queue row ID. It is for one-to-one mail a podcaster starts, such as a guest’s recording details or a preview link for a sponsor.
No unsubscribe link and no opt-out check. It is mail sent to one person, and there is no account to hold a preference, so the unsubscribe link and List-Unsubscribe headers are never added. benecaster_email_should_send still runs, with no user, so a filter can refuse it.
Written in the site’s language, whatever language the person who started it uses in the admin.
Otherwise it is like every Benecaster send: queued, recorded in the email log under the address, held unsent on a staging copy of the site, and passed through the same filters and the before and after send actions, with no user. WordPress’s personal-data export and erasure find its log rows by the address.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
email |
string |
— | Yes | The recipient's email address. Someone with no account on the site. |
type |
string |
— | Yes | An email type registered with benecaster_managed_email_types. An unregistered type sends nothing. |
subject |
string |
— | Yes | Subject line; merge tags are replaced. '' sends the type's registered default_subject. |
template |
string |
— | Yes | Template name resolved by the renderer. '' uses the type's registered default_template_path. |
context |
array |
[] |
No | Merge-tag context. A show_id key is the send's show and a related_id key its job group, as in benecaster_send_email(). |
Return Value
Type:
int
The benecaster_email_queue row ID, or 0 for an invalid address, an unregistered type, a type with no template, a send a filter refused, or a failure. It is not a delivery result: the queue sends later.
Example
$queue_id = benecaster_send_email_to_address(
'guest@example.com',
'my_plugin_guest_details',
'', // the type's default subject
'', // the type's default template
[ 'show_id' => $show_id, 'recording_time' => '2027-03-04 15:00' ]
);
if ( 0 === $queue_id ) {
// An invalid address, an unregistered type, or a filter refused it.
}
Notes
Only for people without an account. It skips opt-outs by design, so never use it to reach a subscriber or a follower. Anyone with an account gets benecaster_send_email(), which applies theirs.
Only for a registered type. Register yours in benecaster_managed_email_types with a default_subject and a default_template_path, then pass '' for both. An unregistered type returns 0.
For one-off mail with no registered type behind it, use benecaster_mail().
Need this built rather than just documented? See our services →