I tried several functions found on the internet and i don't seem to figure what the problem is... this is one of the example i tryied
Expand|Select|Wrap|Line Numbers
- function sendMail($sendto, $subject, $message, $from, $filesToAttach=NULL)
- {
- $i=0;
- $mime_boundary = md5(time());
- $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section
- $msg = "--".$mime_boundary."\r\n";
- $msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"\r\n\r\n";
- # HTML Version
- $msg .= "--".$htmlalt_mime_boundary."\r\n";
- $msg .= "Content-Type: text/html; charset=iso-8859-1\r\n";
- $msg .= "Content-Transfer-Encoding: 8bit\r\n";
- $msg .= $message."\r\n\r\n";
- //close the html/plain text alternate portion
- $msg .= "--".$htmlalt_mime_boundary."--\r\n\r\n";
- while (isset($filesToAttach[$i]))
- {
- $fileSize = filesize($filesToAttach[$i]);
- $fileType = filetype($filesToAttach[$i]);
- // get the content of the file in a string
- $PtrAttachedFile = fopen($filesToAttach[$i],"r");
- $StrAttachedFile = fread($PtrAttachedFile, $fileSize);
- fclose($PtrAttachedFile);
- //base64 encoding. Because the file must be in this format to be sent with a mail client
- $FileToAttach64 = base64_encode($StrAttachedFile);
- //RFC 2045 norm
- $FileToAttach64 = chunk_split($FileToAttach64, 64 , "\r\n");
- //Creation of the header. The "--some random text " string is to mark the file to send. It is used later in the $sender.
- $HeaderAttachedFile = "\r\n--".$mime_boundary."\r\nContent-Type: ".$fileType.";\r\n name=\"".$filesToAttach[$i]."\"\r\n"."Content-Transfer-Encoding: base64\r\nContent-Disposition: attachment;\r\n filename=\"".$filesToAttach[$i]."\"\r\n\r\n";
- // we specify the attachement in the recipient
- $msg .="\r\n".$HeaderAttachedFile.$FileToAttach64;
- $i++;
- }
- $msg .= "--".$mime_boundary."--\r\n\r\n";
- $sender .= "MIME-Version: 1.0\nContent-Type: multipart/mixed;".chr(13).chr(10).chr(9)."boundary=\"".$mime_boundary."\"\n";
- $a=mail($sendto, $subject, $msg, $sender);
- return $a;
- }
If anybody can point out to what i am doing wrong, i will be gratefull
thanks