Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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
Can';t在不丢失附件的情况下向PHP添加消息体_Php - Fatal编程技术网

Can';t在不丢失附件的情况下向PHP添加消息体

Can';t在不丢失附件的情况下向PHP添加消息体,php,Php,我终于拼凑出一个代码,允许我将一个FDF文件从我的服务器发送到电子邮件,而不会将我的文件缩减为0kb的附件。问题是,我必须摆脱电子邮件的主体才能做到这一点 我希望能够将HTML(或纯文本)正文添加到正在发送的电子邮件中。有点像: <h2>DWR Submittal</h2> <p>Process the attachment in the system.</p> STEP 1. Download file STEP 2. Open with Ad

我终于拼凑出一个代码,允许我将一个FDF文件从我的服务器发送到电子邮件,而不会将我的文件缩减为0kb的附件。问题是,我必须摆脱电子邮件的主体才能做到这一点

我希望能够将HTML(或纯文本)正文添加到正在发送的电子邮件中。有点像:

<h2>DWR Submittal</h2>
<p>Process the attachment in the system.</p>

STEP 1. Download file
STEP 2. Open with Adobe Acrobat
STEP 3. Verify form data
STEP 4. etc...
STEP 5. etc...
DWR提交文件
在系统中处理附件

第一步。下载文件 第二步。用AdobeAcrobat打开 第三步。验证表单数据 第四步。等 第五步。等
在不影响附件的情况下,在何处或如何进行此操作

<?php
  $fileatt = './dwrdocuments/dwr.fdf'; // Path to the file
  $fileatt_type = "application/octet-sdiveam"; // File Type
  $fileatt_name = date(mdy_his).'_dwr.fdf'; 
  $email_from = $_POST['From']; // Who the email is from
  $email_subject = 'DWR Submittal'; // The Subject of the email
  $email_txt = $_POST['Comments']; // Message that the email has in it

  $email_to = 'admin@example.com'; // Who the email is to

  $headers = "From: ".$email_from;

  $file = fopen($fileatt,'rb');
  $data = fread($file,filesize($fileatt));
  fclose($file);

  $semi_rand = md5(time());
  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

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

  $email_message .= "This is a multi-part message in MIME format.\n\n" .
  "--{$mime_boundary}\n" .
  "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
  "Content-divansfer-Encoding: 7bit\n\n" .
  $email_message . "\n\n";

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

  $email_message .= "--{$mime_boundary}\n" .
  "Content-Type: {$fileatt_type};\n" .
  " name=\"{$fileatt_name}\"\n" .
  //"Content-Disposition: attachment;\n" .
  //" filename=\"{$fileatt_name}\"\n" .
  "Content-Transfer-Encoding: base64\n\n" .
  $data . "\n\n" .
  "--{$mime_boundary}--\n";

  $ok = @mail($email_to, $email_subject, $email_message, $headers);
  header ("Location: ../confirm.html");  
?>

尝试添加:

$email_message .= '<h2>DWR Submittal</h2>
<p>Process the attachment in the system.</p>

STEP 1. Download file
STEP 2. Open with Adobe Acrobat
STEP 3. Verify form data
STEP 4. etc...
STEP 5. etc...';

松散和失去是两个不同的词。
$data = chunk_split(base64_encode($data));