Макс
весь код составления аттача занимает ровно столько же места, сколько вызов этого класса.
Вот не понимаю я, когда для таких примитивных операций пишут здоровенные классы.
<?php
##########################################
#Copyright © 2001 Wanja Hemmerich
# First version published May 2001 - This version August 2001
##########################################
function sendmsg($to, $subject, $text, $from, $file, $type) {
$content = fread(fopen($file,"r"),filesize($file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = basename($file);
$header = "From: $from\\nReply-To: $from\\n";
$header .= "MIME-Version: 1.0\\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\\n";
$header .= "--$uid\\n";
$header .= "Content-Type: text/plain\\n";
$header .= "Content-Transfer-Encoding: 8bit\\n\\n";
$header .= "$text\\n";
$header .= "--$uid\\n";
$header .= "Content-Type: $type; name=\\"$name\\"\\n";
$header .= "Content-Transfer-Encoding: base64\\n";
$header .= "Content-Disposition: attachment;
$ilename=\\"$name\\"\\n\\n";
$header .= "$content\\n";
$header .= "--$uid--";
mail($to, $subject, "", $header);
return true;
}
?>
sendmsg() is a function that allows you to send eMails with
attachments. The function is built up like this:
sendmsg(string to, string subject, string body, string from , string path_of_file, string filetype);
Explaination:
1. string to: to which eMailadresse will the eMail with_
attachment be sent.
2. string subject: what subject will the eMail have?
3. string body: will the also have some body text, or just the_
attachment?
4. string from: Who sent the eMail?
5. string path_of_file: which file should be sent. Which path_
does it have?
6. string filetype: which filetype does the file have, that_
should be sent?
Here are some possible filetypes:
image/gif = GIF picture
image/jpeg = JPEG picture
image/png = PNG picture
application/x-zip-compressed = Compressed ZIP
application/x-gzip = Compressed GZ
application/x-tar = Compressed TAR
Here\'s an example how the function should be used:
sendmsg("webmaster@w3secrets.xxx", "Hi Webmaster", "Hi Webmaster!\\n\\nyou have a great script!", "picture.gif", "image/gif");