0

错误:警告:mail() [function.mail]:mail() 函数的参数错误,未发送邮件。在 /home/content/19/10977719/html/turgut/email/send.php 第 59 行

我正在尝试发送带有附件的邮件。它显示错误。

它无需附件即可工作,但我不需要它。

这不起作用,同样的错误: http: //www.vivekmoyal.in/send-email-attachment-in-php-send-attachment-in-email-php/

这是我的 php 代码:

    $upload_name=$_FILES["upload"]["name"];
    $upload_type=$_FILES["upload"]["type"];
    $upload_size=$_FILES["upload"]["size"];
    $upload_temp=$_FILES["upload"]["tmp_name"];

    $fp = fopen($upload_temp, "rb");
    $file = fread($fp, $upload_size);

    $file = chunk_split(base64_encode($file));
    $num = md5(time());     

$ad     = $_POST['ad'];   
$email  = $_POST['email'];
$r_email  = $_POST['r_email'];
$msg    = $_POST['msg'];
$subject    = $_POST['konu'];



       $headers  .= "MIME-Version: 1.0\r\n";
       $headers  .= "Content-Type: multipart/mixed; ";
       $headers  .= "boundary=".$num."\r\n";
       $headers  .= "--$num\r\n";

       // spamden kaçmak için bir yöntem

       $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
       $headers .= "X-Mailer: PHP v".phpversion()."\r\n";

                // With message

    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
       $headers .= "Content-Transfer-Encoding: 8bit\r\n";
       $headers .= "".$msg."\n";
       $headers .= "--".$num."\n";

        // Attachment headers

    $headers  .= "Content-Type:".$upload_type." ";
       $headers  .= "name=\"".$upload_name."\"r\n";
       $headers  .= "Content-Transfer-Encoding: base64\r\n";
       $headers  .= "Content-Disposition: attachment; ";
       $headers  .= "filename=\"".$upload_name."\"\r\n\n";
       $headers  .= "".$file."\r\n";
       $headers  .= "--".$num."--";

$mailsonuc = mail("$r_email","$subject","$msg", $headers); 

这是html:

<form id="attach" name="attach" action="gonder.php" method="post" enctype="multipart/form-data">
            <h1>{TOP_MSG}</h1>

            <table border="0" width="650">
    <tr>
        <td valign=middle>{NAME}</td>
        <td>:</td>
        <td><input type="text" placeholder="Adınız Soyadınız" required name="ad" /></td>
    </tr>
    <tr>
        <td valign=middle>{SENDER}</td>
        <td>:</td>
        <td><input type="text" placeholder="E-Posta Adresiniz" required name="email" /></td>
    </tr>
        <tr>
        <td valign=middle>{RECEIVER}</td>
        <td>:</td>
        <td><input type="text" placeholder="Alıcı E-Posta Adresi" required name="r_email" /></td>
    </tr>

    <tr>
        <td valign=middle>{KONU}</td>
        <td>:</td>
        <td><textarea name="konu"  required="" cols="46" rows="1"></textarea></td>
    </tr>
    <tr>
        <td valign=middle>{MESSAGE}</td>
        <td>:</td>
        <td><textarea name="msg"  required="" cols="46" rows="7"></textarea></td>
    </tr>
        <tr>
        <td valign=middle>{EK}</td>
        <td>:</td>
        <td> <input type="file" name="upload" id="upload"></td>
    </tr>

    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
</table>        

            <div align="center">
                <input type="submit" value="Gönder" id="send" name="send" />
            </div>
        </form>
4

2 回答 2

0

我认为您的问题仅基于小错误。

  1. 检查您的 PHP 版本
  2. 邮寄您的托管公司并向他们报告。
  3. 尝试删除密件抄送:标题,看看是否有效。

简单的搜索结果

也参考这个链接:

这是文件上传的示例

否则,请不要建立自己的 MIME 电子邮件。使用PHPMailerSwiftmailer,它们几乎可以为您完成所有工作。您可以用大约 5 或 6 行代码替换整个脚本。除非您也可以 参考此链接

于 2013-07-15T13:53:37.227 回答
0

我有同样的问题,并注意到我<p>在主题行中有 HTML 字符。一旦删除,它就起作用了。

于 2015-07-10T17:01:09.347 回答