我目前正在使用以下代码在发布新帖子时向用户发送电子邮件,但我需要它以密件传给所有用户,而不是所有用户。有什么想法吗?
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\');
SO网友:fuxia
第一:不要使用mail()
. Use wp_mail()
相反
wp_mail(
// Send it to yourself
get_option( \'admin_email\' ),
\'Your subject\',
\'Your message\',
// extra headers
array (
\'Bcc:\' . implode( ",", $usersarray ),
\'From:\' . get_option( \'admin_email\' )
)
);