Index: includes/mail.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/mail.inc,v
retrieving revision 1.7
diff -u -p -r1.7 mail.inc
--- includes/mail.inc	4 Sep 2007 21:10:45 -0000	1.7
+++ includes/mail.inc	25 Jan 2008 11:02:55 -0000
@@ -276,6 +276,7 @@ function drupal_html_to_text($string, $a
   // Replace inline <a> tags with the text of link and a footnote.
   // 'See <a href="http://drupal.org">the Drupal site</a>' becomes
   // 'See the Drupal site [1]' with the URL included as a footnote.
+  _drupal_html_to_mail_urls(NULL, TRUE);
   $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i';
   $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);
   $urls = _drupal_html_to_mail_urls();
@@ -429,17 +430,24 @@ function _drupal_wrap_mail_line(&$line, 
  *
  * Keeps track of URLs and replaces them with placeholder tokens.
  */
-function _drupal_html_to_mail_urls($match = NULL) {
+function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
   global $base_url, $base_path;
   static $urls = array(), $regexp;
-  if (empty($regexp)) {
-    $regexp = '@^'. preg_quote($base_path, '@') .'@';
+  
+  if ($reset) {
+    // Reset internal URL list.
+    $urls = array();
   }
-  if ($match) {
-    list(, , $url, $label) = $match;
-    // Ensure all URLs are absolute.
-    $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url);
-    return $label .' ['. count($urls) .']';
+  else {
+    if (empty($regexp)) {
+      $regexp = '@^'. preg_quote($base_path, '@') .'@';
+    }
+    if ($match) {
+      list(, , $url, $label) = $match;
+      // Ensure all URLs are absolute.
+      $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url);
+      return $label .' ['. count($urls) .']';
+    }
   }
   return $urls;
 }
