PHP电子邮件表单回复



我试图创建一个带有附件的邮件表单,其中回复地址与收到的地址不同。他们接收电子邮件可以正常工作,但如果您决定回复他们,它会在回复电子邮件的末尾添加 mime 版本。(例如:email@gmail.commime-version)请参阅下面的代码。

<?php
// Email address to which you want to send email
$to = $_POST["gut"];

$subject = $_POST["fieldSubject"];
$message = nl2br($_POST["fieldDescription"]);
/*********Creating Uniqid Session*******/
$txtSid = md5(uniqid(time()));
$headers = "";
$headers .= "From: ".$_POST["fieldFormName"]."<".$_POST["fieldFormus"].">nReply-To: ".$_POST["fieldFormEmail"]."";
$headers .= "MIME-Version: 1.0" . "n";
$headers .= "Content-Type: multipart/mixed; boundary="".$txtSid.""nn";
$headers .= "This is a multi-part message in MIME format.n";
$headers .= "--".$txtSid."n";
$headers .= "Content-type: text/html; charset=utf-8n";
$headers .= "Content-Transfer-Encoding: 7bitnn";
$headers .= $message."nn";
/***********Email Attachment************/
if($_FILES["attachment"]["name"] != "")
{
    $txtFilesName = $_FILES["attachment"]["name"];
    $txtContent = chunk_split(base64_encode(file_get_contents($_FILES["attachment"]["tmp_name"]))); 
    $headers .= "--".$txtSid."n";
    $headers .= "Content-Type: application/octet-stream; name="".$txtFilesName.""n"; 
    $headers .= "Content-Transfer-Encoding: base64n";
    $headers .= "Content-Disposition: attachment; filename="".$txtFilesName.""nn";
    $headers .= $txtContent."nn";
}
// @ is for skiping Errors //
$flgSend = @mail($to,$subject,null,$headers);  
if($flgSend)
{
    echo 'Your email as being sent successFully.';
}
else

{ ?>

如果更改以下内容会发生什么:

$headers .= "From: ".$_POST["fieldFormName"]."<".$_POST["fieldFormus"].">nReply-To: ".$_POST["fieldFormEmail"]."";

$headers .= "From: ".$_POST["fieldFormName"]."<".$_POST["fieldFormus"].">nReply-To: ".$_POST["fieldFormEmail"]."n";

请注意行尾的 。

相关内容

  • 没有找到相关文章

最新更新