$pdfname="test.pdf";
  $email="test@test.com";
  $text = "您好,附件中是您需要的pdf文件。请点击下载。<br><a href=http://www.Cuoxin.com>www.Cuoxin.com</a>";         //文本内容
  $text = base64_encode($text);     //用base64方法把它编码  
  $text = chunk_split($text);     //把这个长字符串切成由每行76个字符组成的小块
  $subject = $pdfname;         //标题  
  $from = "admin@Cuoxin.com";     //发送者  
  $to = $email;     //接受者
  //附件  
  // 定义分界线  
  $boundary = "nextpart_".uniqid("");  
  $boundary2 = "nextpart_".uniqid("");  
  $headers = "to: $torn";
  $headers .= "from: $fromrn";  
  $headers .="mime-version: 1.0rn";
  $headers .= "content-type: multipart/mixed;  
              boundary="----=_$boundary"rn";
  $read=file_get_contents($pdfname);
  $read = base64_encode($read);     //用base64方法把它编码  
  $read = chunk_split($read);     //把这个长字符串切成由每行76个字符组成的小块
  //现在我们可以建立邮件的主体  
  $body = "this is a multi-part message in mime format.
  ------=_$boundary
  content-type: multipart/alternative;
      boundary="----=_$boundary2";
  ------=_$boundary2
  content-type: text/html;
      charset="gbk"
  content-transfer-encoding: base64
  $text
  ------=_$boundary2--
  ------=_$boundary
  content-type: application/octet-stream;
      charset="gbk";
      name="$pdfname"
  content-disposition: attachment; filename="$pdfname"
  content-transfer-encoding: base64
  $read
  -------=_$boundary--";
  if(mail($to, $subject,$body,$headers))  
     echo "您需要的pdf文件(".$pdfname.")已经发往您的邮箱:".$to."。<br>请查收。";  
  else  
     echo "抱歉,发送失败了。<br>"; 

dawei

【声明】:达州站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。