0
My resume is already present in resume folder with following formate

eg: 3chaitanya.doc = > [session_id+session_firstname]

i need to attach it to email without browsing it

<?php
session_start();
include('db.php');
$to = "company@gmail.com";
$fromEmail = $_SESSION['user_email'];
$fromName = "Job tile"; 
$subject = "Applying for job";
$message = "some text";

//path of my resume is
$path ="C:\wamp\www\jobportal-deb\resume\S_SESSION['user_id'].S_SESSION['first_name']";


/* GET File Variables */ 
$tmpName = $_FILES['attachment']['tmp_name']; 
$fileType = $_FILES['attachment']['type']; 
$fileName = $_FILES['attachment']['name']; 

echo $tmpName.'<br/>';
echo $fileType.'<br/>';
echo $fileName.'<br/>';

/* Start of headers */ 
$headers = "From: $fromName"; 

if (file($tmpName)) { 
  /* Reading file ('rb' = read binary)  */
  $file = fopen($tmpName,'rb'); 
  $data = fread($file,filesize($tmpName)); 
  fclose($file); 

  /* a boundary string */
  $randomVal = md5(time()); 
  $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; 

  /* Header for File Attachment */
  $headers .= "\nMIME-Version: 1.0\n"; 
  $headers .= "Content-Type: multipart/mixed;\n" ;
  $headers .= " boundary=\"{$mimeBoundary}\""; 

  /* Multipart Boundary above message */
  $message = "This is a multi-part message in MIME format.\n\n" . 
  "--{$mimeBoundary}\n" . 
  "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 
  "Content-Transfer-Encoding: 7bit\n\n" . 
  $message . "\n\n"; 

  /* Encoding file data */
  $data = chunk_split(base64_encode($data)); 

  /* Adding attchment-file to message*/
  $message .= "--{$mimeBoundary}\n" . 
  "Content-Type: {$fileType};\n" . 
  " name=\"{$fileName}\"\n" . 
  "Content-Transfer-Encoding: base64\n\n" . 
  $data . "\n\n" . 
  "--{$mimeBoundary}--\n"; 
} 

$flgchk = mail ("$to", "$subject", "$message", "$headers"); 

if($flgchk){
  echo "A email has been sent to: $to";
 }
else{
  echo "Error in Email sending";
}
?>

Edited by chaitu11

2
Contributors
3
Replies
17
Views
3 Years
Discussion Span
Last Post by chaitu11
0

i have resume which is saved in resume folder ... i need to attach it mail on applying job. with out browse option

0
Solved
<?php
session_start();
include 'db.php';
include 'user_header.php';
include('function.php');
check_session($con);

$sql = mysqli_query($con,"select user_id,resume from user_personal_details where
user_id = '".$_SESSION['user_id']."'");

$row = mysqli_fetch_array($sql);

$resumename = $row['resume'];
/***************************************************/
$to = "company@gmail.com";
$fromEmail = $_SESSION['user_email'];
$fromName = "Job title"; 
$subject = "Applying for job";
$message = "some text";

$tmpName = "resume/$resumename"; 
$fileType = "application/msword";
$fileName = $tmpName;

//echo $tmpName.'<br/>';
//echo $fileType.'<br/>';
//echo $fileName.'<br/>';

/* Start of headers */ 
$headers = "From: $fromName"; 

if (file($tmpName)) { 
  /* Reading file ('rb' = read binary)  */
  $file = fopen($tmpName,'rb'); 
  $data = fread($file,filesize($tmpName)); 
  fclose($file); 

  /* a boundary string */
  $randomVal = md5(time()); 
  $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; 

  /* Header for File Attachment */
  $headers .= "\nMIME-Version: 1.0\n"; 
  $headers .= "Content-Type: multipart/mixed;\n" ;
  $headers .= " boundary=\"{$mimeBoundary}\""; 

  /* Multipart Boundary above message */
  $message = "This is a multi-part message in MIME format.\n\n" . 
  "--{$mimeBoundary}\n" . 
  "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 
  "Content-Transfer-Encoding: 7bit\n\n" . 
  $message . "\n\n"; 

  /* Encoding file data */
  $data = chunk_split(base64_encode($data)); 

  /* Adding attchment-file to message*/
  $message .= "--{$mimeBoundary}\n" . 
  "Content-Type: {$fileType};\n" . 
  " name=\"{$fileName}\"\n" . 
  "Content-Transfer-Encoding: base64\n\n" . 
  $data . "\n\n" . 
  "--{$mimeBoundary}--\n"; 
} 

$flgchk = mail ("$to", "$subject", "$message", "$headers"); 

if($flgchk){
  echo "A email has been sent to: $to";
 }
else{
  echo "Error in Email sending";
}
?>
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.