/**
  * Send an e-mail or a text message to a recipient .
  *
  * @since 0.1
  */
 function wp_crm_send_notification($action = false, $args = false)
 {
     global $wp_crm, $wpdb;
     if (!$action) {
         return false;
     }
     $defaults = array('force' => false);
     if (!is_array($args)) {
         $args = wp_parse_args($args, $defaults);
     }
     if (empty($args)) {
         return false;
     }
     $notifications = WP_CRM_F::get_trigger_action_notification($action, $args['force']);
     if (!$notifications) {
         return false;
     }
     //** Act upon every notification one at a time */
     foreach ($notifications as $notification) {
         $message = WP_CRM_F::replace_notification_values($notification, $args);
         if (!$message) {
             continue;
         }
         $headers = "From: {$message[send_from]} \r\n\\";
         add_filter('wp_mail_content_type', create_function('', 'return "text/html"; '));
         if ($wp_crm['configuration']['do_not_use_nl2br_in_messages'] == 'true') {
             $message['message'] = $message['message'];
         } else {
             $message['message'] = nl2br($message['message']);
         }
         $result = wp_mail($message['to'], $message['subject'], $message['message'], $headers, $args['attachments'] ? $args['attachments'] : false);
     }
 }