php-多部分/混合电子邮件表单数据中md5的用途

我想知道以下PHP代码段(发现herehere)中md5(“ sanwebe”)校验和的目的.
“ sanwebe”参数有什么作用?

if($file_attached) //continue if we have the file
{
  $boundary = md5("sanwebe"); 
  //header
  $headers = "MIME-Version: 1.0\r\n"; 
  $headers .= "From:".$from_email."\r\n"; 
  $headers .= "Reply-To: ".$email."" . "\r\n";
  $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n"; 

  //plain text 
  $body = "--$boundary\r\n";
  $body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
  $body .= "Content-Transfer-Encoding: base64\r\n\r\n"; 
  $body .= chunk_split(base64_encode($message_body)); 

  //attachment
  $body .= "--$boundary\r\n";
  $body .="Content-Type: $file_type; name=\"$file_name\"\r\n";
  $body .="Content-Disposition: attachment; filename=\"$file_name\"\r\n";
  $body .="Content-Transfer-Encoding: base64\r\n";
  $body .="X-Attachment-Id: ".rand(1000,99999)."\r\n\r\n"; 
  $body .= $encoded_content; 
}else{
  //proceed with PHP email.
  $headers = "From:".$from_email."\r\n".
  'Reply-To: '.$email.'' . "\n" .
  'X-Mailer: PHP/' . phpversion();
  $body = $message_body;
}

解决方法:

md5(“ sanwebe”)的结果被用作电子邮件中内容不同部分的边界.

为什么是“ sanwebe”?完全没有理由.您在那里的代码段可能已发布在sanwebe.com上(一个快速的Google带来了一对夫妇),或者是从最初存在的代码段派生而来.关于“ sanwebe”没有什么特别的,您也可以使用md5(“ *”).

上一篇:Java:InputStream转换为多部分文件,结果文件为空


下一篇:springmvc上传文件错误The current request is not a multipart request