Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以加密格式交付的PHP电子邮件附件_Php_Email_Attachment_Encryption - Fatal编程技术网

以加密格式交付的PHP电子邮件附件

以加密格式交付的PHP电子邮件附件,php,email,attachment,encryption,Php,Email,Attachment,Encryption,我试图触发一个带有电子邮件附件的表单。但是由于某种原因,附件,附件是以加密格式发送的。谁能帮帮我吗。。。。 要求是连同附件一起填写表格,所有详细信息都需要发送到电子邮件id,没有任何问题 <?php if(isset($_POST['submit'])){ // Obtain file upload vars $tmp_name = $_FILES['filename']['tmp_name']; $type = $_FILES['filename']['type'];

我试图触发一个带有电子邮件附件的表单。但是由于某种原因,附件,附件是以加密格式发送的。谁能帮帮我吗。。。。 要求是连同附件一起填写表格,所有详细信息都需要发送到电子邮件id,没有任何问题

<?php

if(isset($_POST['submit'])){


// Obtain file upload vars
   $tmp_name = $_FILES['filename']['tmp_name'];
   $type = $_FILES['filename']['type'];
   $file_name = $_FILES['filename']['name'];
   $size = $_FILES['filename']['size'];


$name = trim($_POST['name']); 
$age = trim($_POST['age']);
$sex = $_POST['sex'];
$occupation = trim($_POST['occupation']);
$address = trim($_POST['address']);
$email = trim($_POST['email']);
$hphone = trim($_POST['hphone']);
$cphone = trim($_POST['cphone']);
$treatment = trim($_POST['treatment']);
$symptom = trim($_POST['symptom']);
$thistory = trim($_POST['thistory']);
$currmedic = trim($_POST['currmedic']);
$otherprobs = trim($_POST['otherprobs']);
$contactmode = trim($_POST['contactmode']);
$contactinfo = trim($_POST['contactinfo']);
$agree = $_POST['agree'];

$subject = "Request for Consultation from " .$name;  

$isError = "N";

if($name == "") {
    $nameErrMsg = "Enter your name.";
    $nameErr = "1" ;
    $isError = "Y";
}

if($age == "") {
    $ageErrMsg = "Enter your age.";
    $ageErr = "1";
    $isError = "Y"; 
}

if(!isset($sex))
{
    $sexErrMsg = "Select your Gender.";
    $sexErr = "1";
    $isError = "Y";
}

if($address == "") {
    $addressErrMsg = "Enter your Address.";
    $addressErr = "1";
    $isError = "Y";
}

if($email == "") {
    $emailErrMsg = "Enter your Email.";
    $emailErr = "1";
    $isError = "Y";
} //check for valid email
elseif(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
    $emailErrMsg = 'You did not enter a valid Email.';
    $emailErr = "1";
    $isError = "Y";
}

if($cphone == "") {
    $cphoneErrMsg = "Enter your Cell Phone.";
    $cphoneErr = "1";
    $isError = "Y";
}

if($treatment == "") {
    $treatmentErrMsg = "Enter your required Treatment.";
    $treatmentErr = "1";
    $isError = "Y";
}

if($symptom == "") {
    $symptomErrMsg = "Enter the Symtoms.";
    $symptomErr = "1";
    $isError = "Y";
}

if($thistory == "") {
    $thistoryErrMsg = "Enter Treatment History.";
    $thistoryErr = "1";
    $isError = "Y";
}

if($contactinfo == ""){
    $contactinfoErrMsg = "Enter Contact Info.";
    $contactinfoErr = "1";
    $isError = "Y";
}

if(!isset($agree))
{
    $agreeErrMsg = "Select for Agree/Disagree to use your medical information in case studies.";
    $agreeErr = "1";
    $isError = "Y";
}


if($isError == "N")
{
$message = "
Name : $name <br />
Age : $age <br />
Sex : $sex <br />
Occupation : $occupation <br />
Address : $address <br />
Email : $email <br />
Home Phone : $hphone <br />
Cell Phone : $cphone <br />
Treatment For : $treatment <br /> 
Symptoms : $symptom  <br />
Treatment History : $thistory <br />
Current Medications : $currmedic <br />
List out any other associated conditions or health problems that your suffering with : $otherprobs <br />
Preferred mode of Contact : $contactmode <br />
Contact Info : $contactinfo <br />
Agree to use your medical information in case studies : $agree 
";
    $file = fopen($tmp_name,'rb');
    $data = fread($file,filesize($tmp_name));
    fclose($file);
    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

    //$headers = "From: $from\r\n" .
        // "MIME-Version: 1.0\r\n" .
      //   "Content-Type: multipart/mixed;\r\n" .
       //  " boundary=\"{$mime_boundary}\"";

    $message = "\n" .
         //"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
         //"Content-Transfer-Encoding: 7bit\n\n" .
         $message . "\n\n";


    $data = chunk_split(base64_encode($data));

    $message .= //"--{$mime_boundary}\n" .

         "Content-Type: {$type};\n" .
         "File Name=\"{$file_name}\"\n" .
         //"Content-Disposition: attachment;\n" .
         //" filename=\"{$fileatt_name}\"\n" .
         //"Content-Transfer-Encoding: base64\n\n" .
         $data . "\n\n" ;

//if (is_uploaded_file($fileatt)) 
//{

//}

$to = "anand.pikay@gmail.com";
$headers = 'From: '.$email.'' . "\r\n" .    
            'Reply-To: '.$email.'' . "\r\n" .
            'data: '.$data.'' . "\r\n" .    


    enter code here

    'Content-type: text/html; charset=utf-8' . "\r\n" .    'X-Mailer: PHP/' . phpversion();

$send_email = mail($to,$subject,$message,$headers);

if($send_email)
{ 
    $msg= "Your message sent successfully.";
    $name = ""; 
    $age = "";
    $sex = "";
    $occupation = "";
    $address = "";
    $email = "";
    $hphone = "";
    $cphone = "";
    $treatment = "";
    $symptom = "";
    $thistory = "";
    $currmedic = "";
    $otherprobs = "";
    $contactmode = "";
    $contactinfo = "";
    $agree = "";
}
else
{
    $errorMsg = "Error in sending email!!!";
}
}
}
?>
您已注释掉//内容传输编码:base64\n\n。接收方如何知道如何解码?此外,仅使用经验证的软件包(如PHPMailer)即可节省大量时间和麻烦。