forse non ti ho capito ma a me fa quello che vuoi tu....
questo è il codice ciao
non ne so molto di php ma penso che molte cose siano superflue in questo codice....Codice PHP:
$filename = 'contatti.txt';
$file = file_get_contents($filename);
$fp = fopen($filename, "w");
fwrite($fp, "\r\nNUOVO MESSAGGIO:\r\n $headers \r\n OGGETTO:\r\n $oggetto \r\n MESSAGGIO:\r\n $messaggio\r\n-------------\r\n");
fwrite($fp, $file);
fclose($fp);