|
復制代碼 代碼如下:
<?
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);
}
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 -- 下 主站蜘蛛池模板: 2020亚洲色噜噜狠狠网站 | 亚洲99精品A片久久久久久 | 最近韩国日本免费观看mv免费版 | 色欲色香天天天综合 | 国偷自产视频一区二区99 | 伦理电影v男人天堂 | 国产精品99久久久久久AV | 蜜臀AV精品久久无码99 | 三级全黄的视频 | 天天夜夜草草久久亚洲香蕉 | 国产精品日本欧美一区二区 | 三级成年网站在线观看 | 在线观看亚洲免费人成网址 | 美艳人妻在厨房翘着屁股 | 又黄又爽又无遮挡在线观看免费 | 国产高清视频在线观看97 | 精品人妻一区二区三区视频53 | 久久不射网 | 亚洲日韩欧美国产专区 | 亚洲精品久久YY5099 | 日韩高清在线亚洲专区 | 亚洲综合色在线视频久 | 成人精品视频在线观看播放 | 久久AV亚洲精品一区无码网 | 成人免费视频在线播放 | 色狗综合网 | 欧美激情视频一区 | 日本工口生肉全彩大全 | 欧美亚洲国产手机在线有码 | 久久久久99精品成人片三人毛片 | 欧美xxxx印度 | 久久99re2在线视频精品 | 在线电影一区二区 | 国产精品亚洲精品久久国语 | 精品亚洲AV无码蜜芽麻豆 | 18video性欧美19sex高清 | 狠狠色狠狠色综合系列 | 97色伦图区97色伦综合图区 | proburn中文破解版下载 | 亚洲伊人久久精品 | 99视频在线看观免费 |