Hi all... For more days, I am struggling with one damn concept.. I have created a sample mail sending code which supports to upload our resume and send it to some company person.. I have cleared many bugs and finally it works fine. But the problem is when i host it with web server (live server) and send a mail with attachment of my resume, the mail has sent successfully but the attachment of my resume is not well. This is not attached well in the mail. The contents of the resume are encoded and that encoded format only attached directly to mail body and sent.. I need to do the attachment as a file. I already worked with PHP mailer script with SMTP configuration. It also works fine in localhost, but not functioning (no errors also displayed, only blank page displayed) in web server (live server). Anybody, please help to kill this and make me to win this challenge.. Here is the Code...
<?php
session_start();
$target_path="uploads/";
$fileatt_name = $_FILES['uploadval']['name'];
$fileatt_type = $_FILES['uploadval']['type'];
$fileatt_tempname=$_FILES['uploadval']['tmp_name'];
$email_subject = "Resume ";
$email_to = "xxx@yyy.com";
$fil=$target_path.$_FILES['uploadval']['name'];
if(file_exists($fil))
{
unlink($fil);
/*echo "Sorry file already exists and it has been deleted...";
exit;*/
}
if(move_uploaded_file($_FILES['uploadval']['tmp_name'],$target_path.$_FILES['uploadval']['name']))
{
/*print_r ($_FILES);
$target_path.basename($_FILES['uploadval']['tmp_name']*/
$fileatt =$target_path.$_FILES['uploadval']['name'];
$file = fopen($fileatt,"rb");
$data = fread($file,filesize($fileatt));
fclose($file);
$comments = $_REQUEST['comments'];
$data = chunk_split(base64_encode($data));
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "\n MIME-Version: 1.0 \n";
$headers.="Content-Type: multipart/mixed;\n";
$headers.=" boundary=\"{$mime_boundary}\"\n";
$message=" ";
$message.="\n\n"."\"--{$mime_boundary}\"\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1?\"\n";
$message.="Content-Transfer-Encoding: 7bit\n";
$message.=$message."\n\n";
/* $message.="--$semi_rand\n\n"; */
$message.="--{$mime_boundary}\n";
$message.="Content-Type: \"{$fileatt_type}\"\n";
$message.="name= \"{$fileatt_name}\"\n";
$message.="Content-Disposition: attachment;\n";
$message.="filename=\"{$fileatt_name}\"\n";
$message.="Content-Transfer-Encoding: base64\n\n";
$message.=$data;
$message.="\n\n"."--{$mime_boundary}--\n";
$message.="Comments :".$comments."\n\n";
$ok = mail($email_to,$email_subject,$message,$headers);
if($ok)
{
echo "<font face=verdana size=2>Thankyou for uploading your resume to our website... We will call you soon if you are getting shortlisted....</font>";
}
else
{
echo("Sorry, Unable to send your resume now. Please go back and try again!");
}
}
?>
This is very urgent now... Thanks in advance for your help...!