Hii,
I have solved all the problems i have given . i have tried the code to send 2 attachments also it worked as a singel file...but when i used the code in smarty engine its not recognizing the headers.its printing as it is in the mail.
the code for it is
[PHP]<?
require_once('libs/Smarty.class.php');
$smarty = new Smarty;
//require_once('db.inc');
$smarty->compile_dir = 'templates_c/';
$smarty->assign("TPL_Name",$_POST['Name']);
$smarty->assign("TPL_DOB",$_POST['DOB']);
$smarty->assign("TPL_Gender",$_POST['Gender']);
$smarty->assign("TPL_Nationality",$_POST['Nationality']);
$smarty->assign("TPL_Affiliation",$_POST['Affiliation']);
$smarty->assign("TPL_Email",$_POST['Email']);
$smarty->assign("TPL_Phone",$_POST['Phone']);
$smarty->assign("TPL_Fax",$_POST['Fax']);
$smarty->assign("TPL_PostalAddress",$_POST['PostalAddress']);
$smarty->assign("TPL_PermanentAddress",$_POST['PermanentAddress']);
$smarty->assign("TPL_Degree1",$_POST['Degree1']);
$smarty->assign("TPL_Institute1",$_POST['Institute1']);
$smarty->assign("TPL_University1",$_POST['University1']);
$smarty->assign("TPL_Year1",$_POST['Year1']);
$smarty->assign("TPL_Class1",$_POST['Class1']);
$smarty->assign("TPL_Rank1",$_POST['Rank1']);
$smarty->assign("TPL_Major1",$_POST['Major1']);
$smarty->assign("TPL_Degree2",$_POST['Degree2']);
$smarty->assign("TPL_Institute2",$_POST['Institute2']);
$smarty->assign("TPL_University2",$_POST['University2']);
$smarty->assign("TPL_Year2",$_POST['Year2']);
$smarty->assign("TPL_Class2",$_POST['Class2']);
$smarty->assign("TPL_Rank2",$_POST['Rank2']);
$smarty->assign("TPL_Major2",$_POST['Major2']);
$smarty->assign("TPL_Degree3",$_POST['Degree3']);
$smarty->assign("TPL_Institute3",$_POST['Institute3']);
$smarty->assign("TPL_University3",$_POST['University3']);
$smarty->assign("TPL_Year3",$_POST['Year3']);
$smarty->assign("TPL_Class3",$_POST['Class3']);
$smarty->assign("TPL_Rank3",$_POST['Rank3']);
$smarty->assign("TPL_Major3",$_POST['Major3']);
$smarty->assign("TPL_Degree4",$_POST['Degree4']);
$smarty->assign("TPL_Institute4",$_POST['Institute4']);
$smarty->assign("TPL_University4",$_POST['University4']);
$smarty->assign("TPL_Year4",$_POST['Year4']);
$smarty->assign("TPL_Class4",$_POST['Class4']);
$smarty->assign("TPL_Rank4",$_POST['Rank4']);
$smarty->assign("TPL_Major4",$_POST['Major4']);
$smarty->assign("TPL_PhDTopic",$_POST['PhDTopic']);
$smarty->assign("TPL_Referee1",$_POST['Referee1']);
$smarty->assign("TPL_Referee2",$_POST['Referee2']);
$smarty->assign("TPL_Justify",$_POST['Justify']);
$smarty->assign("TPL_TravelSupport",$_POST['TravelSupport']);
$smarty->assign("TPL_TravelSupportNeed",$_POST['TravelSupportNeed']);
$smarty->assign("TPL_city",$_POST['city']);
$smarty->assign("TPL_post",$_POST['post']);
$smarty->assign("TPL_country",$_POST['country']);
$smarty->assign("TPL_pcity",$_POST['pcity']);
$smarty->assign("TPL_ppost",$_POST['ppost']);
$smarty->assign("TPL_pcountry",$_POST['pcountry']);
$smarty->assign("TPL_sample",$_POST['sample']);
$smarty->assign("TPL_TSD",$_POST['TSD']);
$smarty->assign("TPL_cv",$_FILES['cv']['name']);
$smarty->assign("TPL_publication",$_FILES['publication']['name']);
$fileatt = $_FILES['cv']['tmp_name'];
$fileatt_type = $_FILES['cv']['type'];
$fileatt_name = $_FILES['cv']['name'];
print_r($_FILES['cv']);
print_r($_FILES['publication']);
$fileatt1 = $_FILES['publication']['tmp_name'];
$fileatt1_type = $_FILES['publication']['type'];
$fileatt1_name = $_FILES['publication']['name'];
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$file1 = fopen($fileatt1,'rb');
$data1 = fread($file1,filesize($fileatt1));
fclose($file1);
if($_POST['TPL_Flag']!="Mail"){
$smarty->assign("TPL_Flag",'Preview');
$smarty->display('appnew.tpl');
}else{
$smarty->assign("TPL_Flag",'Mail');
$msg=$smarty->fetch('appnew.tpl');
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\r\nMIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;" .
" boundary=\"{$mime_boundary}\"\r\n";
// Add a multipart boundary above the plain message
$message1 .= "This is a multi-part message in MIME format" . $mime_boundary . "\r\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\r\n" .
"Content-Transfer-Encoding: 7bit\r\n" .
$msg . "\r\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
$data1 = chunk_split(base64_encode($data1));
// Add file attachment to the message
$message1 .= "--{$mime_boundary}\r\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\r\n" .
"Content-Transfer-Encoding: base64\r\n" .
$data . "\r\n";
$message1 .= "--{$mime_boundary}\r\n" .
"Content-Type: {$fileatt1_type};\r\n" .
" name=\"{$fileatt1_name}\"\r\n" .
"Content-Transfer-Encoding: base64\r\n" .
$data1 . "\r\n" .
"--{$mime_boundary}--\r\n";
$sub = "Astrostat School Application from " . $_POST['Name'] . "," .$_POST['country'];
//$headers = "From: ";
$headers = "From: \r\nContent-Type: text/html; charset=\"iso-8859-1\"\r\n";
$to = "";
$mail_ret =@mail($to, $sub, $message1, $headers);
if($mail_ret){
$message ="Your application for the 2nd IIA-PennState Astrostatistics school has been successfully submitted.";
}else{
$message ="Registration failed. Please try after some time.";
}
//Display message in a template
$smarty->assign("TPL_Message",$message);
$smarty->Display("newmessage.tpl");
}
?>[/PHP]
and in the mail at begging its printing as This is a multi-part message in MIME format==Multipart_Boundary_x96a252f89aecb7b6374843 7f2ce20e62x Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit
and at the end
--==Multipart_Boundary_x96a252f89aecb7b63748437f2ce2 0e62x Content-Type: ; name="" Content-Transfer-Encoding: base64 --==Multipart_Boundary_x96a252f89aecb7b63748437f2ce2 0e62x Content-Type: ; name="" Content-Transfer-Encoding: base64 --==Multipart_Boundary_x96a252f89aecb7b63748437f2ce2 0e62x--
Thanks,
Pradeep