How can I reference a contact's Drupal/Wordpress/Joomla account with a CiviMail token?
Option 1: Use the CiviToken extension [recommended, CMS independent]: 
Fuzion's CiviToken extension provides {user.name} and {user.id} tokens by default. (Pro tip: this module also makes it easy to add custom tokens in a tokens/ folder in your CiviCRM custom PHP directory; you can duplicate and modify a file from the tokens/ folder in this extension)

Option 2: Custom token in your own Drupal module [Drupal specific]: 
Coleman authored a blog post some years back which outlined how to make custom tokens. The following snippet is based on that and when slipped into a custom module will make the Drupal username available as a token in CiviMail.

&lt;?php
/* CiviCRM token addition for Drupal username */

function MYMODULE_civicrm_tokens(&amp;$tokens) {
  $tokens['username'] = array(
    'username.drupal' =&gt; 'Drupal username',
  );
}

function MYMODULE_civicrm_tokenValues(&amp;$values, $cids, $job = null, $tokens = array(), $context = null) {
  // Username tokens
  if (!empty($tokens['username'])) {

    civicrm_initialize();
    foreach ($cids as $cid) {
      $params = array(
        'version' =&gt; 3,
        'sequential' =&gt; 1,
        'contact_id' =&gt; $cid,
      );
      $result = civicrm_api('UFMatch', 'get', $params);
      if (!$result['is_error']) {
        $drupalinfo = user_load($result['values'][0]['uf_id']);
        $values[$cid]['username.drupal'] = $drupalinfo-&gt;name;
      }
    }

  }
}
?&gt;


Keep in mind that this is the bare bones and doesn't include any handling of a contact without a Drupal account. (So you would want to make sure to only use this token when sending to contacts with a Drupal account.)