Hello, I need to attach multiple txt files in a mail, this is not the problem. The problem is that I'm loading the content out of MySQL and saving these txt files will be waste of time. How can I attach multiple txt files with content loaded out of MySQL without being a txt file? So it's 'on the fly'. Thanks in advance, Michael EDIT: I've this so far: $to = urldecode($_GET['to']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $query = mysql_query("SELECT * FROM `task` WHERE `pid` = '$id'") or die(mysql_error()); while($r = mysql_fetch_array($query)){ $content = $r['title']." ".$r['content']; $content_encode = chunk_split(base64_encode($content)); $r['title'] = preg_replace("/ /i", "_", $r['title']); $message .= "Content-Type: text/plain; name=\"{$r['title']}.txt\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment\n"; $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; } $headers = "From: xxx@xxx.com\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail($to, 'Test', $message, $headers); Code (markup): But it only shows "ATT00001" in the attachments list and has no content, what am I doing wrong?