- $Size = strlen($body);
-
- /*
- * This is here in case we ever decide to use highlighting of searched
- * text. this does it for email addresses
- *
- * if ($what && ($where == "BODY" || $where == "TEXT")) {
- * eregi ($Email_RegExp_Match, $body, $regs);
- * $oldaddr = $regs[0];
- * if ($oldaddr) {
- * $newaddr = eregi_replace ($what, "<b><font color=\"$color[2]\">$what</font></font></b>", $oldaddr);
- * $body = str_replace ($oldaddr, "<a href=\"../src/compose.php?send_to=$oldaddr\">$newaddr</a>", $body);
- * }
- * } else {
- * $body = eregi_replace ($Email_RegExp_Match, "<a href=\"../src/compose.php?send_to=\\0\">\\0</a>", $body);
- * }
- */
-
- if( eregi($Email_RegExp_Match, $body, $regs) ) {
+ $sbody = $body;
+ $addresses = array();
+
+ /* Find all the email addresses in the body */
+ while(eregi($Email_RegExp_Match, $sbody, $regs)) {
+ $addresses[$regs[0]] = $regs[0];
+ $start = strpos($sbody, $regs[0]) + strlen($regs[0]);
+ $sbody = substr($sbody, $start);
+ }
+ /* Replace each email address with a compose URL */
+ foreach ($addresses as $email) {
+ $comp_uri = '../src/compose.php?send_to='.urlencode($email);