emailclass.php
复制代码 代码如下:
<?
class CMailFile {
var $subject;
var $addr_to;
var $text_body;
var $text_encoded;
var $mime_headers;
var $mime_boundary = "--==================_846811060==_";
var $smtp_headers;
function CMailFile($subject,$to,$from,$msg,$filename,$downfilename,$mimetype = "application/octet-stream",$mime_filename = false) {
$this->subject = $subject;
$this->addr_to = $to;
$this->smtp_headers = $this->write_smtpheaders($from);
$this->text_body = $this->write_body($msg);
$this->text_encoded = $this->attach_file($filename,$downfilename,$mimetype,$mime_filename);
$this->mime_headers = $this->write_mimeheaders($filename, $mime_filename);
}
function attach_file($filename,$downfilename,$mimetype,$mime_filename) {
$encoded = $this->encode_file($filename);
if ($mime_filename) $filename = $mime_filename;
$out = "--" . $this->mime_boundary . "\n";
$out = $out . "Content-type: " . $mimetype . "; name=\"$filename\";\n";
$out = $out . "Content-Transfer-Encoding: base64\n";
$out = $out . "Content-disposition: attachment; filename=\"$downfilename\"\n\n";
$out = $out . $encoded . "\n";
$out = $out . "--" . $this->mime_boundary . "--" . "\n";
return $out;
}
function encode_file($sourcefile) {
if (is_readable($sourcefile)) {
$fd = fopen($sourcefile, "r");
$contents = fread($fd, filesize($sourcefile));
$encoded = chunk_split(base64_encode($contents));
fclose($fd);
}
return $encoded;
}
function sendfile() {
$headers = $this->smtp_headers . $this->mime_headers;
$message = $this->text_body . $this->text_encoded;
mail($this->addr_to,$this->subject,$message,$headers);
} www.jb51.net
function write_body($msgtext) {
$out = "--" . $this->mime_boundary . "\n";
$out = $out . "Content-Type: text/plain; charset=\"us-ascii\"\n\n";
$out = $out . $msgtext . "\n";
return $out;
}
function write_mimeheaders($filename, $mime_filename) {
if ($mime_filename) $filename = $mime_filename;
$out = "MIME-version: 1.0\n";
$out = $out . "Content-type: multipart/mixed; ";
$out = $out . "boundary=\"$this->mime_boundary\"\n";
$out = $out . "Content-transfer-encoding: 7BIT\n";
$out = $out . "X-attachments: $filename;\n\n";
return $out;
}
function write_smtpheaders($addr_from) {
$out = "From: $addr_from\n";
$out = $out . "Reply-To: $addr_from\n";
$out = $out . "X-Mailer: PHP3\n";
$out = $out . "X-Sender: $addr_from\n";
return $out;
}
}
/*用法 - 例如:mimetype 为 "image/gif"
$mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filename,$mimetype);
$mailfile->sendfile();
$subject -- 主题
$sendto -- 收信人地址
$replyto -- 回复地址
$message -- 信件内容
$filename -- 附件文件名
$downfilename -- 下載的文件名
$mimetype -- mime类型
*/
?>
演示示例
复制代码 代码如下:
<?php
require_once('emailclass.php');
//发送邮件
//主題
$subject = "test send email";
//收件人
$sendto = 'abc@163.com';
//發件人
$replyto = 'cdf@163.com';
//內容 www.jb51.net
$message = "test send email content";
//附件
$filename = 'test.jpg';
//附件類別
$mimetype = "image/jpeg";
$mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filename,$excelname,$mimetype);
$mailfile->sendfile();
?>
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
- 群星《2024好听新歌34》AI调整音效【WAV分轨】
- 《剑星》新体模晒超美工作照:身材出众迷人眼!
- 《潜行者2》Xbox平台已开放预载!大小约147GB
- 《剑星》与《尼尔》联动让玩家狂喜:我就是为这而活!
- 刘德华《金碟至尊精选24K》 GOLD[WAV+CUE][1.1G]
- 窦唯《雨吁》上海音像首版[WAV分轨][1G]
- 群星《2024好听新歌03》十倍音质 U盘音乐 [WAV分轨][1.1G]
- 《原神》5.1上半深渊第12层配队打法攻略
- 《原神》彩糖与蔷薇的幻色颂玩法说明
- 《原神》5.1上半期卡池角色培养一图流
- 潘越云.1999-唯一潘越云2CD【滚石】【WAV+CUE】
- 文章.2024-致青春【川合音乐】【FLAC分轨】
- 董文华.2006-池中萍【杰盛唱片】【WAV+CUE】
- 谭艳-《再度重相逢》限量编号1:1黄金母盘直刻[低速原抓WAV+CUE]
- 格格《倾国倾城》DTS-ES6.1[WAV]