| 域名空间 下载中心 社区论坛 信息公告 my小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
收发发附件?http://www.iyit.net 日期:2006-10-6 15:32:34 来源:iyit.net收集 点击: |
请问怎么用mail发附件? 怎么用imap收附件? (别的方法也可以) --------------------------------------------------------------- 我贴,已测试通过 <? class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body; function mime_mail(){ $this->parts = array(); $this->to = ""; $this->from = ""; $this->subject = ""; $this->body = ""; $this->headers = ""; } function add_attachment($message, $name = "", $ctype = "application/octet-stream") { $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name ); } function build_message($part) { $message = $part["message"]; $message = chunk_split(base64_encode($message)); $encoding = "base64"; return "content-type: ".$part["ctype"]. ($part["name"]?"; name = \"".$part["name"]."\"" : ""). "\ncontent-transfer-encoding: $encoding\n\n$message\n"; } function build_multipart(){ $boundary = "b".md5(uniqid(time())); $multipart = "content-type: multipart/mixed; boundary = $boundary\n\nthis is a mime encoded message.\n\n--$boundary"; for($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->build_message($this->parts[$i])."--$boundary"; } return $multipart.= "--\n"; } function send() { $mime = ""; if (!empty($this->from)) $mime .= "from: ".$this->from."\n"; if (!empty($this->headers)) $mime .= $this->headers."\n"; if (!empty($this->body)) $this->add_attachment($this->body, "", "text/plain"); $mime .= "mime-version: 1.0\n".$this->build_multipart(); mail($this->to, $this->subject, "", $mime); } }; // end of class //$attachment = fread(fopen("test.jpg", "r"), filesize("test.jpg")); //这里也得去掉,但是你的test.jpg必须存在 $mail = new mime_mail(); $mail->from = "gfqqqqpe@163.com"; //这是出处 $mail->headers = "errors-to: gfqqqqpe@163.com"; $mail->to = "gfqqqqpe@163.com"; //这是戏子的邮箱,在这里你可以改成你的邮箱发一下 $mail->subject = 'test...';//这是标题 $mail->body = 'ok!'; //这是内容 //$mail->add_attachment("$attachment", "test.jpg", "image/jpeg"); //去掉注释,你就以发附件 $mail->send(); print "ok,成功完成!"; ?> 这是发附件 --------------------------------------------------------------- function get_part (&$stream, &$msg_number, $mime_type, $structure = false, $part_number = false) { if (!$structure) { $structure = imap_fetchstructure($stream, $msg_number); } if($structure) { if(strtolower ($mime_type) == get_mime_type($structure)) { if(!$part_number) { $part_number = "1"; } if ($structure->ifdisposition) { if (strtolower ($structure->disposition) == "attachment") return false; } $text = imap_fetchbody($stream, $msg_number, $part_number); if($structure->encoding == 3) { return imap_base64($text); } else if($structure->encoding == 4) { return imap_qprint($text); } else { return $text; } } if($structure->type == 1) /* multipart */ { while(list($index, $sub_structure) = each($structure->parts)) { if($part_number) { $prefix = $part_number . '.'; } $data = get_part($stream, $msg_number, $mime_type, $sub_structure, $prefix . ($index + 1)); if($data) { return $data; } } } } return false; } 编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:请问怎么分离得出ip里的前2(3)个ip段用于实现封ip功能?……来不及琢磨正则表达式了~:( 下一篇:关于unixstamp的问题?有请各路高手,绝对不简单的问题 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 相关文章 | ||||
| 友情链接 | ||||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||