0

受信アドレスと返信アドレスが異なる添付ファイル付きメールフォームを作成しようとしています。メールの受信は正常に機能しますが、返信することにした場合、返信メールの最後に mime-version が追加されます。(例: 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."\"\n\n";
$headers .= "This is a multi-part message in MIME format.\n";

$headers .= "--".$txtSid."\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
$headers .= $message."\n\n";

/***********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: base64\n";
    $headers .= "Content-Disposition: attachment; filename=\"".$txtFilesName."\"\n\n";
    $headers .= $txtContent."\n\n";
}

// @ is for skiping Errors //
$flgSend = @mail($to,$subject,null,$headers);  

if($flgSend)
{
    echo 'Your email as being sent successFully.';
}
else

{ ?>

4

1 に答える 1