dsjk3214 2016-12-15 06:56
浏览 8

附件不在邮件PHP中显示

I am working on enquiry form and all things are working fine. But issue is that when user attach the file it will comes on server but not show in my inbox. pls help me to solve this. here is my PHP code:

<?php
include('conn/conn.php');
if(isset($_POST['Submit'])){
$name                   =   $_POST['name'];
$email                  =   $_POST['email'];
$mobile                 =   $_POST['mobile'];
$age                    =   $_POST['age '];
$gender                 =   $_POST['gender'];
$city                   =   $_POST['city'];
$presentquali           =   $_POST['presentquali'];
$experience             =   $_POST['experience'];
$sapcertificate         =   $_POST['sapcertificate'];
$yearobtain             =   $_POST['yearobtain'];
$currentsalary          =   $_POST['currentsalary'];
$expectedsalary         =   $_POST['expectedsalary'];
$skills                 =   $_POST['skills'];
$designation            =   $_POST['designation'];
$jobprofile             =   $_POST['jobprofile'];
$passport               =   $_POST['passport'];
$clientsideexp          =   $_POST['clientsideexp'];
$countryname            =   $_POST['countryname'];
$germanlanguage         =   $_POST['germanlanguage'];
$germanlanguagelevel    =   $_POST['germanlanguagelevel'];
$relocate               =   $_POST['relocate'];
$maritalstatus          =   $_POST['maritalstatus'];
$query                  =   $_POST['query'];    

$t_email = array("abc@dummy.net");
// multiple recipients
foreach($t_email as $key=>$index){
$to = $t_email[$key];

// subject
$subject = 'Enquiry Details';

// message
$message = '
<html>
<head>
<title>Enquiry Details</title>
</head>
<body>
<p>Here are the Detail- </p>
<table>
';
if($name!=''){
$message .= '
<tr>
<td>Name -</td>
<td>'.$name.'</td>
</tr>
    ';
    }
    if($email!=''){
    $message .= '
        <tr>
          <td>Email -</td>
          <td>'.$email.'</td>
        </tr>

    ';
    }
    if($mobile!=''){
    $message .= '
        <tr>
          <td>Mobile -</td>
          <td>'.$mobile.'</td>
        </tr>
    ';
    }
    if($age!=''){
    $message .= '
        <tr>
          <td>Age -</td>
          <td>'.$age.'</td>
        </tr>
    ';
    }
    if($gender!=''){
    $message .= '
        <tr>
          <td>Gender -</td>
          <td>'.$gender.'</td>
        </tr>
    ';
    }
    if($city!=''){
    $message .= '
        <tr>
          <td>Present Location City -</td>
          <td>'.$city.'</td>
        </tr>
    ';
    }
    if($presentquali!=''){
    $message .= '
        <tr>
          <td>Qualification -</td>
          <td>'.$presentquali.'</td>
        </tr>
    ';
    }
    if($experience!=''){
    $message .= '
        <tr>
          <td>Experience in Years -</td>
          <td>'.$experience.'</td>
        </tr>
    ';
    }
    if($sapcertificate!=''){
    $message .= '
        <tr>
          <td>SAP Certification -</td>
          <td>'.$sapcertificate.'</td>
        </tr>
    ';
    }
    if($yearobtain!=''){
    $message .= '
        <tr>
          <td>Year-In Obtained -</td>
          <td>'.$yearobtain.'</td>
        </tr>
    ';
    }
    if($currentsalary!=''){
    $message .= '
        <tr>
          <td>Salary in INR/Per Month -</td>
          <td>'.$currentsalary.'</td>
        </tr>
    ';
    }
    if($expectedsalary!=''){
    $message .= '
        <tr>
          <td>Expected Salary -</td>
          <td>'.$expectedsalary.'</td>
        </tr>
    ';
    }
    if($skills!=''){
    $message .= '
        <tr>
          <td>Skills -</td>
          <td>'.$skills.'</td>
        </tr>
    ';
    }
    if($designation!=''){
    $message .= '
        <tr>
          <td>Designation -</td>
          <td>'.$designation.'</td>
        </tr>
    ';
    }
    if($jobprofile!=''){
    $message .= '
        <tr>
          <td>Brief Job Profile/Role -</td>
          <td>'.$jobprofile.'</td>
        </tr>
    ';
    }
    if($passport!=''){
    $message .= '
        <tr>
          <td>Have Passport Y/N -</td>
          <td>'.$passport.'</td>
        </tr>
    ';
    }
    if($clientsideexp!=''){
    $message .= '
        <tr>
          <td>Client Side / On-site Experience Yes/No -</td>
          <td>'.$clientsideexp.'</td>
        </tr>
    ';
    }
    if($countryname!=''){
    $message .= '
        <tr>
          <td>If Yes Countries visited -</td>
          <td>'.$countryname.'</td>
        </tr>
    ';
    }
    if($germanlanguage!=''){
    $message .= '
        <tr>
          <td>Knowledge of German or DutchLanguage -</td>
          <td>'.$germanlanguage.'</td>
        </tr>
    ';
    }
    if($germanlanguagelevel!=''){
    $message .= '
        <tr>
          <td>If Yes proficiency in Languages: (Excellent/Good/Average) -</td>
          <td>'.$germanlanguagelevel.'</td>
        </tr>
    ';
    }
    if($relocate!=''){
    $message .= '
        <tr>
          <td>Time required to relocate to Germany /Holland -</td>
          <td>'.$relocate.'</td>
        </tr>
    ';
    }
    if($maritalstatus!=''){
    $message .= '
        <tr>
          <td>Married/Single -</td>
          <td>'.$maritalstatus.'</td>
        </tr>
    ';
    }
    if($query!=''){
    $message .= '
        <tr>
          <td>Query -</td>
          <td>'.$query.'</td>
        </tr>
    ';
    }

    $message .= '
        </table>
    </body>
    </html>
    ';



    //attachment
    if(isset($_FILES['fileupload'])){
      $errors= array();
      $file_name = $_FILES['fileupload']['name'];
      $file_size = $_FILES['fileupload']['size'];
      $file_tmp = $_FILES['fileupload']['tmp_name'];
      $file_type = $_FILES['fileupload']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['fileupload']['name'])));

      $expensions= array("doc","docx");

      if(in_array($file_ext,$expensions)=== false){

         //things we need
         $file = $file_name;
         $content = chunk_split(base64_encode(file_get_contents($file)));
         $uid = md5(uniqid(time()));

         //declaring we have multiple kinds of email
         $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"

";
         $header .= "This is a multi-part message in MIME format.
";

         //plain text part
         $header .= "--".$uid."
";
         $header .= "Content-type:text/plain; charset=iso-8859-1
";
         $header .= "Content-Transfer-Encoding: 7bit

";
         $header .= $message."

";

         //file attached
         $header .= "--".$uid."
";
         $header .= "Content-Type: ".$file_type."; name=\"".$file_name."\"
";
         $header .= "Content-Transfer-Encoding: base64
";
         $header .= "Content-Disposition: attachment; filename=\"".$file_name."\"
";
         $header .= $content."

";

        $errors[]="File type not allowed.";
      }

      if($file_size > 2097152) {
         $errors[]='File size must be excately 2 MB';
      }

      if(empty($errors)==true) {
         move_uploaded_file($file_tmp,"resume/".$file_name);
      }else{
         print_r($errors);
      }
   }
   //attachment end


    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "
";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";

    // Additional headers
    //$headers .= 'To: test <test@example.com>, check <check@example.com>' . "
";
    $headers .= 'From: Senior SAP Consultants Job Opportunities<info@server.com>' . "
";
    //$headers .= 'Cc: test@example.com' . "
";
    //$headers .= 'Bcc: test@example.com' . "
";

    // Mail it
    mail($to, $subject, $message, $headers);
}
}; 
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?