How to automatically email contributors when theirs post is published

When you run a blog with many authors, and you want the author of the post to know that his post has been published but you cannot email contributors each time their posts is published, so for that I have a solution for automatically email contributors of post that their post is published.

Well it is really simple just you have to paste the below code :

function wpden_authorNotification($post_id) {
   $post = get_post($post_id);
   $author = get_userdata($post->post_author);

   $message = "
      Hi ".$author->display_name.",
      Your post, ".$post->post_title." has just been published. Well done!
   wp_mail($author->user_email, "Your article is online", $message);
add_action('publish_post', 'wpden_authorNotification');

Now every time you publish the post the WordPress will email contributors of the respective posts. also take a look at How to Automatically notify users on new post

Subscribe to WPDEN