You are here

function _support_mail_notify in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support.module \_support_mail_notify()

Use drupal_mail to send email.

1 call to _support_mail_notify()
support_notification in ./support.module
Send notification emails to everyone subscribed to the updated ticket.

File

./support.module, line 1706
support.module

Code

function _support_mail_notify($op, $account, $comment = array(), $nid = NULL, $suppress = FALSE, $language = NULL) {
  $notify = variable_get('support_mail_' . $op . '_notify', TRUE);
  if ($notify) {
    $node = node_load($nid);
    $params['account'] = $account;
    $params['nid'] = $nid;
    if (isset($comment['cid'])) {
      $params['cid'] = $comment['cid'];
      $params['comment'] = $comment;
    }
    else {
      $params['cid'] = 0;
    }
    $params['suppress'] = $suppress;
    $language = $language ? $language : user_preferred_language($account);
    $params['integrate_email'] = db_result(db_query('SELECT integrate_email FROM {support_client} WHERE clid = %d', $node->client));
    if ($params['integrate_email'] == TRUE) {
      $mailfrom = db_result(db_query('SELECT mailfrom FROM {support_client} WHERE clid = %d', $node->client));
    }
    else {
      $mailfrom = variable_get('support_global_mailfrom', '');
    }
    if (function_exists('mimemail')) {
      $params['message_html_filter'] = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT);
      $message['params'] = $params;

      // Build a message.
      support_mail($op, $message, $params, TRUE);
      $message['body'] = check_markup($message['body'], $params['message_html_filter'], FALSE);
      $mail = mimemail($mailfrom, $account->mail, $message['subject'], $message['body'], FALSE, $message['headers']);
    }
    else {
      $mail = drupal_mail('support', $op, $account->mail, $language, $params, $mailfrom);
    }
  }
  return empty($mail) ? NULL : $mail['result'];
}