Ugur Ozer
Ugur Ozer

Reputation: 49

Sending Auto Mails for new posts from wordpress

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

Answers (1)

Bindiya Patoliya
Bindiya Patoliya

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

Related Questions