å¨drupalç模åå¼åä¸å®ç°åé®ä»¶çåè½é常ç®åï¼åªç¨å°ä¸ä¸ªé©åå½æ° hook_mail åä¸ä¸ªæ¥å£å½æ°drupal_mail.
使ç¨æ¹æ³å¦ä¸ï¼
<?php
function example_mail($key, &$message, $params) {
$language = $message['language'];
$variables = user_mail_tokens($params['account'], $language);
switch($key) {
case 'notice':
$message['subject'] = t('Notification from !site', $variables, $language->language);
$message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, $language->language);
break;
}
}
function example_notify($accounts) {
foreach ($accounts as $account) {
$params['account'] = $account;
// example_mail() will be called based on the first drupal_mail() parameter.
drupal_mail('example', 'notice', $account->mail, user_preferred_language($account), $params);
}
}
?>
温馨提示:答案为网友推荐,仅供参考