I am currently using the below code to email users when a new post is published, but I need it to BCC all users and not TO all users. Any ideas?
function email_members($post_ID) {
global $wpdb;
$usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
$users = implode(",", $usersarray);
mail($users, "New WordPress recipe online!", 'A new recipe have been published on http://www.wprecipes.com');
return $post_ID;
}
add_action('publish_post', 'email_members');
First: Donât use
mail()
. Usewp_mail()
instead.