+ $body = wrap($body, "", $this->wrap);
+
+ // include attachment in the body
+ if (isset($_FILES['newpj'])) {
+ $this->custom = $this->custom_mp;
+ $body = "\n--".$this->boundary."\n".$this->custom_bd."\n\n".$body."\n--".$this->boundary."\n";
+ $tmpname = $_FILES['newpj']['tmp_name'];
+ $file = basename($_FILES['newpj']['name']);
+ $mime = shell_exec("file -bi $tmpname"); //Because mime_content_type don't work :(
+ if (preg_match("@([^ ]+/[^ ]+); (.*)@", $mime, $format)) {
+ $mime = $format[1];
+ $encod = $format[2];
+ } else {
+ preg_match("@([^ ]+/[^ ]+)\r?\n@", $mime, $format);
+ $mime = $format[1];
+ $encod = 'base64';
+ }
+
+ $body .= 'Content-Type: '.$mime.'; name="'.$file."\"\n";
+ $body .= 'Content-Disposition: attachment; filename="'.$file."\"\n";
+ $body .= 'Content-Transfer-Encoding: '.$encod."\n\n";
+ if ($encod == 'base64') {
+ $body .= chunk_split(base64_encode(fread(fopen($tmpname, 'r'), filesize($tmpname))));
+ } else {
+ $body .= fread(fopen($tmpname, 'r'), filesize($tmpname));
+ }
+ $body .= '--'.$this->boundary.'--';
+ }
+
+ // finalise and post the message
+ $msg .= $this->custom.$this->profile['customhdr']."\n".$body;