欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal发送邮件的例子模块

shiping1 的头像

drupal发送邮件的例子模块  不指定

drupal水滴 , 2012/01/31 19:27 , drupal建站 » drupal模块 , 评论(0) , 阅读(984)  |  |  
drupal发送邮件的例子模块

//发送邮件的模板
function email_example_mail($key, &$message, $params) {
  global $user;

  // Each message is associated with a language, which may or may not be the
  // current user's selected language, depending on the type of e-mail being
  // sent. This $options array is used later in the t() calls for subject
  // and body to ensure the proper translation takes effect.
  $options = array(
    'langcode' => $message['language']->language,
  );

  switch ($key) {
    // Send a simple message from the contact form.
    case 'contact_message':
      $message['subject'] = t('E-mail sent from @site-name', array('@site-name' => variable_get('site_name', 'Drupal')), $options);
      // Note that the message body is an array, not a string.
      $message['body'][] = t('@name sent you the following message:', array('@name' => $user->name), $options);
      // Because this is just user-entered text, we do not need to translate it.

      // Since user-entered text may have unintentional HTML entities in it like
      // '<' or '>', we need to make sure these entities are properly escaped,
      // as the body will later be transformed from HTML to text, meaning
      // that a normal use of '<' will result in truncation of the message.
      $message['body'][] = check_plain($params['message']);
      break;
  }
}

email example
http://drupal.org/node/197122


来自 http://www.majormoves.net/post/952/
普通分类: