您好,我正在通过电子邮件提交 html 表单。服务器端脚本是 PHP 。我的 html 表单是
<form action='sendmail.php' method='post'>
Name:<input type="text" name="name">
File:<input type='file' name='attach'>
<input type="submit">
我用于发送电子邮件的 php 文件是
<?php
$strTo = "xyz@gmail.com";
$strHeader .= "From: ".$_POST["name"]."<".$_POST["name"].">";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";
if($_FILES["attach"]["name"] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}
$flgSend = @mail($strTo,"no-subjet",null,$strHeader);
但它不会进入 if 条件