php邮件发送更改功能从文件发送到变量

i have this php function for send email.

http://pastebin.com/raw.php?i=19ZBg8bX

At the moment this script sends e-mail with an attachment present on the server. I need to modify this script so that it sends email with attachment that is saved in the file as a variable!

exemple :

$filename = "file.txt"
$content "bla bla bla bla bla bla bla"

how can edit this ? im a python coder, php im beginner !