您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php写的发送附件的程序(一)

2025/3/4 2:01:40发布11次查看
heyes
error_reporting(63);
  include('class.html_mime_mail.inc');
/***************************************
  ** example of usage.
  ***************************************/
  /***************************************
  ** read the file background.gif into
  ** $backgrnd.
  ***************************************/
  $filename = 'background.gif';
  $backgrnd = fread($fp = fopen($filename, 'r'), filesize($filename));
  fclose($fp);
/***************************************
  ** read the file test.zip into $attachment.
  ***************************************/
  $filename = 'example.zip';
  $attachment = fread($fp = fopen($filename, 'r'), filesize($filename));
  fclose($fp);
/***************************************
  ** create the mail object. optional headers
  ** argument. do not put from: here, this
  ** will be added when $mail->send
  ***************************************/
  $mail = new html_mime_mail(x-mailer: html mime mail class\r\n);
/***************************************
  ** if sending an html email, then these
  ** two variables specify the text and
  ** html versions of the mail. don't
  ** have to be named as these are. just
  ** make sure the names tie in to the
  ** $mail->add_html() command further down.
  ***************************************/
  $text = 'this is a test.';
  $html = '    success!';
/***************************************
  ** add the text, html and embedded images.
  ** each embedded image has to be added
  ** using $mail->add_html_image() before
  ** calling $mail->add_html(). the name
  ** of the image should match exactly
  ** (case-sensitive) to the name in the html.
  ***************************************/
  $mail->add_html_image($backgrnd, 'background.gif', 'image/gif');
  $mail->add_html($html, $text);
/***************************************
  ** if not sending an html email, then
  ** this is used to set the plain text
  ** body of the email.
  ***************************************/
  // $mail->body = 'fsss';
/***************************************
  ** this is used to add an attachment to
  ** the email.
  ***************************************/
  $mail->add_attachment($attachment, 'example.zip', 'application/octet-stream');
/***************************************
  ** builds the message.
  ***************************************/
  $mail->build_message();
/***************************************
  ** sends the message. $mail->build_message()
  ** is seperate to $mail->send so that the
  ** same email can be sent many times to
  ** differing recipients simply by putting
  ** $mail->send() in a loop.
  ***************************************/
  $mail->send('','szw@phpexe.com', 'from name', 'szw@phpexe.com', 'subject','');
/***************************************
  ** debug stuff. entirely unnecessary.
  ***************************************/
  echo '
';
  echo $mail->mime;
  echo '
';
  ?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product