dsadsadsa1231 2014-01-30 02:40
浏览 42

使用PHP发送电子邮件时如何删除附件上的回形针

I have another question. I've created a php mail and I want to remove the paper clip attachment since I dont have any attachment to send but when I checked my email it has a paper click attachment. is there a way to remove it? Im using php mail. Thank You

I've comment the attachment part since I'm not using it but it still doesnt work.

Here is my code:

<?php
    /* Set e-mail recipient */
    $myemail = "test@yahoo.com";



    //*** Get values form fields ***//
    $contact = $_POST['contact'];
    $strtitle = $_POST["txtSubject"];
    $type = $_POST['type'];
    $message = $_POST['textarea'];
    $message = wordwrap($message, 70);

    $message = "

                    <b> Contact No:</b>  $contact <br><br>


                        <b>Description:</b><br>
                        $message <br><br>

                        <b>Type</b> : $type


                ";

    //*** Uniqid Session ***//
    $strSid = md5(uniqid(time()));

    $strHeader = "";

    $strHeader .= "MIME-Version: 1.0
";
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"

";
    $strHeader .= "This is a multi-part message in MIME format.
";

    $strHeader .= "--".$strSid."
";
    $strHeader .= "Content-type: text/html; charset=utf-8
";
    $strHeader .= "Content-Transfer-Encoding: 7bit

";
    $strHeader .= $message."

";





    //*** Attachment ***//

    // if($_FILES["fileAttach"]["name"] != "")
    // {
        // $strFilesName = $_FILES["fileAttach"]["name"];
        // $strFileName = ($_FILES["fileAttach"]["size"]  < 1000000);
        // $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"]))); 
        // $strHeader .= "--".$strSid."
";
        // $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"
"; 
        // $strHeader .= "Content-Transfer-Encoding: base64
";
        // $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"

";

         // $strHeader .= $strContent."

";
    // }


    $flgSend = @mail($myemail,$strtitle,null,$strHeader);  // @ = No Show Error //

    if($flgSend)
    {
        echo "<script type='text/javascript'>
                                    alert('Report Successfully Sent');window.location.href='Test2.php';
                                </script>"; 

        // echo "Size: " . ($_FILES["fileAttach"]["size"]);

    }
    else

    //Alert when Cannot connect to server
    {
        echo "<script type='text/javascript'>
                                    alert('Report Failed to Send : Server Connection Timed Out');window.location.href='Test2.php';
                                </script>";

        // echo "Size Failed: " . ($_FILES["fileAttach"]["size"]);

    }


exit();







?>
  • 写回答

1条回答 默认 最新

  • drs3925 2014-01-30 02:51
    关注

    This should do it:

    $strHeader = "";
    
    $strHeader .= "MIME-Version: 1.0
    ";
    
    $strHeader .= "Content-type: text/html; charset=utf-8
    ";
    $strHeader .= "Content-Transfer-Encoding: 7bit
    
    ";
    $strHeader .= $message."
    
    ";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line