ciao a tutti STO IMPAZZENDO.

non riesco a far inviare per mail il contenuto di una funzione collocata nel file function.php

il codice che uso per inviare la mail in html
Codice PHP:
......................    
$messaggio "

    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>

    <html xmlns='http://www.w3.org/1999/xhtml'>

    <head>

    <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />

    </head>

    

    <body style='text-align: center; background:url([url]http://www.sito.it/immagini/sfondo.jpg[/url]) repeat-x; font: 12px Tahoma;'>
    
    ALTRO TESTO "
.invioCarrello()."

    SEGUE ALTRO TESTO

    </body>

    </html>
    "

invece, ecco il codice della funzione. deve inviare il contenuto di un carrello

codice:
function invioCarrello()
{
  global $db;
  $carrello = $_SESSION['carrello'];
  $somma = 0;
  if ($carrello)
  {
    $prodotti = @explode(',',$carrello);
    $acquisti = array();
    foreach ($prodotti as $prodotto)
    {
      $acquisti[$prodotto] = (@isset($acquisti[$prodotto])) ? $acquisti[$prodotto] + 1 : 1;
    }
    echo '<table border="1">';
	echo '<tr><td>Nome</td><td>Aspetto</td><td>Prezzo</td><td>Q.t&agrave;</td><td>Totale</td></tr>';

    foreach ($acquisti as $id=>$quantita)
    {
$query = "SELECT * FROM 1_prodotti WHERE id =".$id;
$result = mysql_query($query) or die (mysql_error());

echo '[list=1]';
while ($f = mysql_fetch_assoc($result)) {

      @extract($f);
      echo '<tr>';
      echo '<td></td>';
      echo '<td>'.$nome.' by '.$marca.'</td>';
      echo '<td>&euro;'.$prezzo.'</td>';
      echo '<td>'.$quantita.'</td>';
      echo '<td>&euro;'.($prezzo * $quantita).'</td>';
      $somma += $prezzo * $quantita;
	  $tara += $quantita * $peso;
      echo '</tr>';
	  }
    }
	
    echo '</table>';
    echo 'Totale Prodotti: &euro; '.number_format($somma,2,',','.').'</br>';
    echo 'Peso Prodotti in Kg: '.number_format($tara,2,',','.').'</br>';

  }else{
    echo 'Il carrello &egrave; vuoto.
';
  }
  return @join('',$result);
}
help mi!