Mail edit + HTML mail + token

Error message

  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; GeSHi has a deprecated constructor in require_once() (line 818 of /home/xenyomed/public_html/sites/all/modules/libraries/libraries.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_required has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; ctools_context_optional has a deprecated constructor in require_once() (line 127 of /home/xenyomed/public_html/sites/all/modules/ctools/ctools.module).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 579 of /home/xenyomed/public_html/includes/menu.inc).

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com.

function modulename_mailkeys() {
    return array(
      'modulename_category_mail' => t('email alert'),
    );
  return NULL;
}
 
function modulename_mail_edit_text($mailkey, $language) {
  global $base_url;
  $message = array();
  switch ($mailkey) {
    case 'modulename_category_mail':
      $message['subject'] = 'A node is created [node:title]';
      $message['body'] = 'node link:[node:url], your selected category : [modulename:maincat]';
    break;
  }
  return $message;
}
 
function modulename_mail_edit_token_types($mailkey) {
  return array('modulename', 'node');
}
 
function modulename_token_info() {
 $type = array(
    'name' => t('modulename'),
    'description' => t('Tokens from modulename module.'),
  );
  return array(
    'types' => array('modulename' => $type),
    'tokens' => array('modulename' => $obj),
  );
}
 
function modulename_token_list($type) {
  $tokens = array();
  if ($type == 'modulename') {
    $tokens['maincat'] = array(
      'maincat' => t('Main category'),
    );
  }
}
 
function modulename_tokens($type, $tokens, $data = array(), options = array()) {
  $values = array();
  foreach ($tokens as $tokens_key => $tokens_val) {
    if ($type == 'modulename') {
      switch ($tokens_key) {
        case "maincat":
          $values[$tokens_val] = $data['modulename']['maincat'];
        break;
      }
    }
  }
  return $values;
}
 
function modulename_sendmail() {
  $maincat = 'cat1';
  $subcat = 'cat2';
  $module = 'modulename';
  $key = 'modulename_category_mail';
  $language = language_default();
  $params['modulename'] = array('maincat' => $maincat);
  $from = NULL;
  $send = TRUE;
  $email = variable_get('site_mail', ''); //send to
  drupal_mail($module, $key, $email, $language, $params, $from, $send);
}
 
/**
 * Send HTML Mail
 * You need *mailsystem, *HTML Mail module enabled.
 * 1. goto admin/config/system/mailsystem
 * 2. Add new setting, select modulename, input "Key" as "modulename_category_mail"
 * 3. After save, "modulename_category_mail" selects HTMLMailSystem
 */
Help Share this Article