How to create a email notification to subscribers and the author who posted a comment programmatically in drupal 7? I want that if a user subscribe to a comments &amp; post that has been posted by an author,  so how i can send mail notification to both the author and the subscriber at the same time.
I want that author should get a notification that he has some comment on his post.
and the subscriber that author has posted some status or post. 

    &lt;?php
/*
 * Implement hook_menu()
 */


function comment_notification_menu(){
  $items=array();
        $items['admin/customize'] = array(
          'title' =&gt; 'Send Comment notifications',
        'discription' =&gt; 'Admin will send notification to user about updates',
        'type' =&gt; MENU_NORMAL_ITEM,
        'page callback' =&gt; 'drupal_get_form',
        'page arguments' =&gt; array('comment_notification_form'),
        'access arguments' =&gt; array('access adminstration page'),
        'access callback' =&gt; TRUE,
          );

  return $items;
}

/**
 * Form Structure
 */

function comment_notification_form($form, &amp;$form_state){
  $form=array();
  $form['send_mail_from']=array(
    '#title' =&gt; 'Send Mail From',
    '#discription' =&gt; 'To whom you want to send form',
    '#row' =&gt; 5,
    '#columns' =&gt; 10,
    '#type' =&gt; 'textfield',
    //'#required' =&gt; TRUE,
    '#default_value' =&gt; variable_get('send_mail_from'),
    );
//here the admin can wite subject for the mail.
  $form['mail_subject']=array(
      '#title' =&gt; 'Subject',
      '#discription' =&gt; 'the purpous of this mail',
      '#type' =&gt; 'textfield',
      '#size' =&gt;149,
      '#maxlenght' =&gt;200,
      '#required'=&gt;TRUE,
      '#default_value' =&gt; variable_get('mail_subject'),
    );
  $form['mail_body']=array(
      '#title' =&gt; 'Body',
      '#discription'=&gt;'the body of your mail.',
      '#type' =&gt; 'textarea',
      '#row' =&gt; 20,
      '#columns' =&gt; 50,
      '#required' =&gt; TRUE,
      '#default_value' =&gt; variable_get('mail_body'),
    );
   $form['mail_bcc']=array(
      '#title' =&gt; 'BCC this mail to all',
      '#type' =&gt; 'checkbox',

    );


   $form['help'] = array(
        '#theme' =&gt; 'token_tree',
        '#token_types' =&gt; array('node') ,
     );

  return system_settings_form($form);
}





/**
 * Implement hook_comment_insert().
 */

/*
 *Implement token_replace(). , variable_get()
 */


function comment_notification_comment_insert($comment){


if ($comment-&gt;field_comment_notification['und'][0]['value'] == '1') {
      global $user;
      if ($user-&gt;uid == 1){

        $user_mail = $user-&gt;mail;//user has login
        //dsm($email);
  }
  else{

       $user_mail = $comment-&gt;mail;//uesr has not login
  }


      $to = $user_mail;
       // $to = 'm.nikhilanant@gmail.com';
      $message = token_replace(variable_get('mail_body')); // Body of your email here.

$subject = token_replace(variable_get('mail_subject')); // subject of e-mail
$body = token_replace(variable_get('mail_body')); //it might be any variable from the form eg. $form_state['values']['your_field']


//params is the array passed to hook_mail function
$params = array(
    'subject' =&gt; $subject,
    'body' =&gt; $body,
    );
      $message = drupal_mail('comment_notification', 'loaded',
        $to,language_default(),
        $params,$to, TRUE);
    }

}




function comment_notification_mail($key, &amp;$message, $params) {
/*dsm($key);
dsm($message);
dsm($params);
*/
  switch($key) {

    case 'loaded':
      $message['subject'] = token_replace(variable_get('mail_subject'));
      $message['body'][] = token_replace(variable_get('mail_body'));
      break;

  }
}
I do not see a way to allow users to subscribe to comment notification, is that your issue?

In case it is you might have to do something like
Create a menu item as 'Subscribe to comments' check this link to ajaxify for menu item. On page callback of your custom menu subscribe the current user(global $user) to the comments, to hold the data you can simply use a custom table let's name as mymoudle_comment_subscription with columns as record_id|uid|comments_on_type|flag update this table in the subscription menu callback,

Rest is what you have covered in your code, i.e. implement hook_comment_update to notify on existing comment update, hook_comment_delete notify user on comment delete, hook_comment_insert notify user on new comment is added. In your hook Implementation query your custom table 'mymoudle_comment_subscription' fetch all uids get user mail by uids or in case you do not allow user to change emails you can store email directly in your custom table and use drupal_mail as your code shows to mail all users.