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...



$fileatt_name = $_FILES['uploadval']['name']; 
$fileatt_type = $_FILES['uploadval']['type']; 

$email_subject = "Resume ";

$email_to = "xxx@yyy.com"; 


/*echo "Sorry file already exists and it has been deleted...";


/*print_r ($_FILES);

$fileatt =$target_path.$_FILES['uploadval']['name'];  

$file = fopen($fileatt,"rb"); 

$data = fread($file,filesize($fileatt)); 


$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.="Content-Type: text/plain; charset=\"iso-8859-1?\"\n";

$message.="Content-Transfer-Encoding: 7bit\n";


/* $message.="--$semi_rand\n\n"; */


$message.="Content-Type: \"{$fileatt_type}\"\n";

$message.="name= \"{$fileatt_name}\"\n";

$message.="Content-Disposition: attachment;\n";


$message.="Content-Transfer-Encoding: base64\n\n";



$message.="Comments :".$comments."\n\n";

$ok = mail($email_to,$email_subject,$message,$headers); 

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>"; 
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...!

Member Avatar

It may be a daft question, but is your form containing the file field set correctly:


is needed for file upload. I assume you'd get errors if not, right?

I don't know where it is used and what is its purpose..? Pls explain me...?

Member Avatar
<form ... enctype="multipart/form-data">

This may or may not solve your problem, but either way.

I don't know if you have ever used this before but after using it for some time, I will never send mail without it. It's an amazing class with a lot of ready made functionality, has been around for a long time and is very well documented.


Sorry guys... Still i didnt fix my probs..
Any help will be appreciated..
Its very urgent..

This code is working fine in localhost... But with live server, it sends mail, but without attachment.. Why..?

Hi guys.. Please debug this code.. Where i am doing wrong..? Struggling for more than 15 days.. Very urgent

Member Avatar

Does your remote SMTP mailer allow attachments like this? I know some hosts insist on including a 'flag' with the mail headers before they will send. Does your host have a bank of scripts that they encourage you to use?


Are you hosting yourself??
If not, then talk to your hoster about this issue ok?