Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How to send the email with resume attachment ,

i take snippet from this place Click here

In this site, snippet works fine,

Even i got the mail, but attachment is not working, am getting attment as noname with 0kb

size file, What is Issue in that snippet ,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
164 views
Welcome To Ask or Share your Answers For Others

1 Answer

 function mail_attachment($to, $subject, $message, $from, $file) {
  // $file should include path and filename
  $filename = basename($file);
  $file_size = filesize($file);
  $content = chunk_split(base64_encode(file_get_contents($file))); 
  $uid = md5(uniqid(time()));
  $from = str_replace(array("
", "
"), '', $from); // to prevent email injection
  $header = "From: ".$from."
"
      ."MIME-Version: 1.0
"
      ."Content-Type: multipart/mixed; boundary="".$uid.""

"
      ."This is a multi-part message in MIME format.
" 
      ."--".$uid."
"
      ."Content-type:text/plain; charset=iso-8859-1
"
      ."Content-Transfer-Encoding: 7bit

"
      .$message."

"
      ."--".$uid."
"
      ."Content-Type: application/octet-stream; name="".$filename.""
"
      ."Content-Transfer-Encoding: base64
"
      ."Content-Disposition: attachment; filename="".$filename.""

"
      .$content."

"
      ."--".$uid."--"; 
  return mail($to, $subject, "", $header);
 }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...