I sent an email in a function.
My email body is like "Hello [user:name], blablablala -- Team [site:name]".
But the token aren't replace by their values in the email.
What's wrong ?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
You need to run token_replace on the email body and pass in the user object for the target user. In your function: $global $user;
$emluser = user_load($user->uid); $body = "Hello [user:name], blablablala -- Team [site:name]"; $body = token_replace($body, array('user' => $emluser));
You don't need to pass anything for the site tokens to be replaced.