benecaster_email_headers
Filters the full headers array passed to wp_mail(). Common uses: add Reply-To for broadcasts, add X- tracking headers (SendGrid, Postmark, Mailgun), add CC/BCC for admin copies. IMPORTANT: Do not remove the List-Unsubscribe and List-Unsubscribe-Post headers that Benecaster automatically adds — removing them risks emails being routed to spam. Type-specific variant: benecaster_email_headers_{type} — 3 params, $email_type omitted.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$headers |
array |
— | Email headers array |
$email_type |
string |
— | Email type string |
$user_id |
int|null |
— | WordPress user ID; null for admin-only emails |
$show_id |
int|null |
— | ID of the show; null when not show-specific |
Returns:
array
Example
add_filter( 'benecaster_email_headers', function( $headers, $email_type, $user_id, $show_id ) {
// Add a Postmark message stream tag for broadcasts.
if ( 'broadcast' === $email_type ) {
$headers[] = 'X-PM-Message-Stream: broadcast';
}
// Add a Reply-To for all emails.
$headers[] = 'Reply-To: hello@mypodcast.com';
return $headers;
}, 10, 4 );