把其他代码贴出来Look Look!

解决方案 »

  1.   

    其他就是email的内容而已。$message定义的是一个html的邮件,我就是想再同时发送一个到两个pdf文件,文件的位置是在网上的,我是在$attachment里给出的,能够认到差不多的大小,应该是找到这个文件了。再来就是发送,用的是 mail ($email, $subject, $message, $headers);
    请各位帮忙了。
      

  2.   

    http://www.yesky.com/SoftChannel/72342371945349120/20020510/1610577.shtml
    http://geo.jlu.edu.cn/date/mypost/show.php?id=32是偶参考的教程,在网上其他地方找到的也是差不多的。
      

  3.   

    邮件的格式不对,你用foxmail打开一个邮件,看看他的源码.你的邮件的“\r\n”加的不全,head和body间的就不全。
      

  4.   

    我没有foxmail,我都是用ultraedit打开的。看不到\r\n,除了foxmail还有其他方法看到\r\n吗?
    之前我也有考虑过这个问题,并在每行后面都加上\r\n,有时候反而让pdf不按照附件方式显示了。
    请问是在每一行后面都加吗?还有分号是不是每行都要加?
      

  5.   

    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "From: XXX<[email protected]>\r\n";
    $headers .= "Content-type: multipart/mixed; boundary=\"4094d055be8ab\"\r\n\r\n"; $message = "--4094d055be8ab
    Content-type: text/html;
    Content-transfer-encoding: 8bit;$message--4094d055be8ab
    Content-Type: application/pdf;
     name=\"1.pdf\"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment;
     filename=\"1.pdf\"
     
    $read--4094d055be8ab--";
      

  6.   

    谢谢,不过好像还是老问题。hahawen帮偶改的是不是:
    1。
    boundary=\"4094d055be8ab\"\r\n\r\n"; 
    加上\r\n\r\n以后无变化。
    如果和上一句前换行的话,就无法正确显示html格式的邮件和pdf附件。全部都是code。
    2。
    另外$message前换了行,也没有帮助。
      

  7.   

    下面是唠叨老大的一个发附件的脚本.<?php
    /*
    $to 目标
    $subject 主题
    $message 正文
    $from 发自
    $content_type 类型
    $attache 附件,文件名放在数组中
    */
    $email = $_POST['email'];
    $email = trim("$email");$message = "hello";function mail2( $to, $subject, $message, $from, $content_type, $attache="") {
      if(!empty($from)) $head = "From: $from\n";
      if(empty($content_type)) $content_type = "text/plain";  if(is_array($attache)) {
        $boundary = "===" . md5(uniqid("")) . "===";
        $head .= "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"";
        $head .= "$boundary\"\n\nThis is a multi-part message in MIME format.\n\n";
        $head .= "--$boundary\n";
        $head .= "Content-Type: $content_type\n";
        $head .= "\n$message\n\n";    while(list($key, $val) = each($attache)) {
          $fd = fopen("$val", "r") or die("unable to open file $val");
          $contents = chunk_split(base64_encode(fread($fd,filesize("$val"))));
          fclose($fd);
          $head .= "--$boundary\n";
          $head .= "Content-Type: application/octet-stream; name=\"".basename($val);
          $head .= "\"\nContent-Transfer-Encoding: BASE64\n";
          $head .= "Content-Disposition: attachment; filename=\"".basename($val);
          $head .= "\"\n\n" . $contents . "\n\n";
        }
        $head .= "--" . $boundary . "--\n\n";
      }else{
        if(!empty($content_type)) {
          $head .= "Content-Type: $content_type\n";
          $head .= "\n$message\n";
        } 
      }
      return mail($to,$subject,"",$head ); 
    } mail2("$email","",$message,"","",array("a.doc"));?>