I know this is an old question/topic, but after searching for information about mail() and attatchement I did not find much information.
Here is the script that worked for me:
$fileinquestion = fopen ('example.txt', 'r');
$readfile = fgets ($fileinquestion);
$hdr .= "Content-Type: $att_type; ";
$hdr .= "name=\"example.txt\"\r\n";
$hdr .= "Content-Disposition: attachment; ";
mail('to_mail_address@server.com', 'Subject line', $readfile, $hdr);
fclose($fileinquestion);
If anyone know how I could add "From: myemailaddress@server.com" to the mail string, please followup.
Kj.