Reputation: 49
How can I send email to a specific mail address automatically whenever a new posts has been publish to wordpress? Thanks.
Upvotes: 0
Views: 226
Reputation: 2764
You can use plugin for this activity to perform. for that you can use Subscriber plugin.
OR
You can add this code into your functions.php
file
function email_members($post_ID) {
global $wpdb;
$usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
$users = implode(",", $usersarray);
mail($users, "New WordPress post!", 'A new post have been published on site name');
return $post_ID;
}
add_action('publish_post', 'email_members');
Upvotes: 2