0

I am sending email with attachments.. but I did not getting any extention in the email.. all the attachments having name noname without extention, if I attach mutiple files then the attachmment also have only one file named noname without extention too..

<?php
if(isset($_POST['send']))
{
include('db.php');

$strTo = $_POST["email"];
$strSubject = stripslashes($_POST["subject"]);
$strMessage = stripslashes($_POST["message"]);
$from = '******@gmail.com'; 
//*** Uniq id Session ***//
$strSid = md5(uniqid(time()));

$strHeader = "";
$strHeader .= "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n"; 
$strHeader .= "Cc: {$_POST['cc']}\r\n";
$strHeader .= "Bcc: {$_POST['bcc']}\r\n";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";

//*** Attachment ***//
for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++)
{
if($_FILES["fileAttach"]["name"][$i] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"][$i];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}
}

$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //

if($flgSend)
{
    header("Location: ".$_SERVER['PHP_SELF']."?id=".$_REQUEST['id']."&msg=Message Send"); 
}
else
{
    header("Location: ".$_SERVER['PHP_SELF']."?id=".$_REQUEST['id']."&msg=Message Not Send"); 
}
}
?>

I got the below code from the web..

2
Contributors
1
Reply
8
Views
4 Years
Discussion Span
Last Post by LastMitch
0

I got the below code from the web..

OK, did you find answer to it? It would be nice if you can explain how you solve it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.