Thanks to the above, I’ve realized my central mistake — I didn’t quite realize that the arguments being passed in were a multi-dimensional array.
For now, I’ve re-implemented the function thus:
function ws_add_site_header($email) {
$email['headers'][] = 'X-WU-Site: ' . parse_url(get_site_url(), PHP_URL_HOST) ;
return $email;
}
My reading of the wp_mail() source (see: https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/pluggable.php#L235) leads me to believe that the headers component can be an array, or a big string, or possibly some horrific mish-mash of the two, but that using an array is probably the safer/more correct option.
I do like the various phpmailer answers, but it just seems a bit cleaner to try to do things using WordPress’ built-ins.
Related Posts:
- wp_mail – Remove sitename from email subject
- Help with filter for wp_notify_moderator()
- Error using wp_mail inside custom function
- Filter wp_mail based on content type
- Editing ‘Password Reset’ E-mail
- How to apply the “retrieve_password_message” filter?
- How to disable all WordPress emails modularly and programatically?
- How to override the email function by using filters? [closed]
- wpmu_signup_user_notification filter not working
- Change email from and display name with a filter action
- wp_mail works with add_action(‘save_post’, …) but not an ajax action
- Is it possible to put the add-filter()-hook into a function?
- How can I change the email that is inside the default email texts of wordpress?
- Which Filter Do I Use To Modify The Subject Of The Retrieve Password Notification Email?
- Email Obfuscation: Is antispambot() Acceptable? [closed]
- arguments for comment_notification_text filter
- Would like to use hook or filters to customize email templates
- Changing WooCommerce Display Price Based on User Role & Category [closed]
- Do something after sending email
- Not able to change wp_title using add_filter
- How to hook a filter to catch get_post_meta when alternate a custom field output?
- Changing JPEG compression depending on image size
- Filter username field on registration for profanity and unwanted words
- At what priority does add_filter overwrite core functions?
- How to add icons to post listing (edit.php) in admin
- Tiny MCE editor stripping xlink:href parameter from SVG USE tag
- Add quick edit fields without custom colum
- Prevent 404 when using pre_get_posts to filter an archive page
- Hook added to the_content seems to be called multiple times
- Keep Users Logged In As Long As I Like
- Is it possible to remove the filter from 4.8 text widget?
- How to remove X-Frame-Options: SAMEORIGIN” from WordPress?
- How can I hide all posts that don’t have a thumbnail?
- Restrict filter to run only inside specific function
- Setting title using wp_title filter
- 4.0 remove_filter for WordPress core function not working for me
- How do I add a current class to the current post?
- How apply_filters work in WordPress?
- Apply a filter only once
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- option_active_plugins filter not working
- How do we check if the user is logging in or registering?
- add_filter return value
- User invite email not delivered – related to subdomain?
- Add a header before fields added with the attachment_fields_to_edit() filter
- Can I configure WordPress to use postfix without a plugin?
- Are there Limitations on filter handles?
- Why my admin doesn’t work after adding rest_prepare_post filter?
- Different Webhost and using Google Mail server: Is there a better way than SMTP?
- remove_action in plugin file
- How to apply filter at search of woocommerce products?
- Adding second Email address for WP user notifications
- PHP mail() works but wp_mail() does not
- Variables in post title
- Filtering post-formats from the loop using new WP-Query();
- How to edit dashboard search posts button texts for my CPT?
- How to add a filter to get_the_author_meta?
- When does a function assigned to the content_filtered_edit_pre filter hook fire?
- Capture post content before page renders
- Empty string supplied as input when parsing content
- How can I remove the kses filters when saving a specific post type ? (it breaks my JSON)
- What different ways can a plugin add a filter to a WordPress site?
- How to pass variables to custom filter from multiple functions
- the_content filter together with require_once returns 1 instead of the content of the included file
- Missing Argument 2 for apply_filter
- Detect when gutenberg editor title is available in Dom after editor load
- How to apply a filter to an ACF wysiwig editor field output?
- Is it possible to bind a function to a filter hook via Ajax?
- Add a filter to an action [closed]
- Why template_include filter does not work with WPML plugin?
- Hide Posts In Back-end/Admin Based On User’s (Pseudo) Privileges Controlled by ACF
- Filter Pages by Custom Field (ACF) in admin area
- Remove tags without a specific meta key from “choose from the most used tags”
- Making an add_filter() call from within an add_filter() call
- automatic title through filter
- Finding actual functions added to hooks and filters
- Images in wp_mail not showing
- Buddypress Filter Multiple Activities [closed]
- How to apply filter on get_the_post_thumbnail()
- How do I check if I can use the allowed_block_types filter?
- oembed_dataparse filter not running at all for standard YouTube embed
- Action for opening attachment or manipulating all attachment links
- Remove the post_content search from WHERE clause (and CONCAT sql function)
- mu-plugins body_class filter not working
- Sending email with wp_email and AJAX
- Conditionally (cpt) filter previous and next_post_link
- Post filter Month dropdown at front-end like wordpress backend
- shortcode function outputs multiple anchor tags
- changing size image within the content
- WP Dashboard -> Posts-> Filter by Category -> Form Method Change : Which Hook
- Show child theme for users on specific IP
- wp.getPosts with status = ‘trash’ using node.js
- Is there a way to overwrite a filter used in canonical.php?
- How do I remove certain HTML elements with specific classes from the feed?
- Adding an orderby filter, casting postmeta with multiple keys
- confusion with add_filter
- post->post_content filter
- How to change this WP logo and posts url in block editor?
- Can you call a filter hook by “add_action”?
- Adding filter to the Contact Form 7 response