<?php
class Mail
{
private $charset = "UTF-8";
private $boundary = "";
private $SubBody = array();
private $body = array();
private $ctencoding = "base64";
private $count_body = 1;
private $checkAddress = true;
private $headers = array();
private $ready_headers = array();
private $names_email = array();
private $receipt = 0;
private $smtpsendto = array();
private $sendto = array();
private $acc = array();
private $abcc = array();
private $smtp = array();
private $smtp_log = '';
private $log_on = false;
private $body_header = array();
public $status_mail = array('status' => true, "message" => 'ок');
public function __construct($charset = "", $ctencoding = '')
{
$this->boundary = md5(uniqid("myboundary"));
$this->smtp['on'] = false;
if (strlen($ctencoding) and $ctencoding == '8bit')
{
$this->ctencoding = '8bit';
}
if (strlen($charset))
{
$this->charset = strtolower($charset);
if ($this->charset == "us-ascii")
{
$this->ctencoding = "7bit";
}
}
}
public function Body($text, $text_html = "", $alternative_text = '', $resource = 'webi')
{
if (!strlen($resource))
$resource = 'webi';
if ($text_html == "html")
$text_html = "text/html";
else
$text_html = "text/plain";
if ($this->ctencoding == 'base64')
{
if (strlen($alternative_text))
$alternative_text = chunk_split(base64_encode($alternative_text));
if (strlen($text))
$text = chunk_split(base64_encode($text));
}
if (!strlen($alternative_text))
{
$body = "Content-Type: ".$text_html."; charset=".$this->charset."\r\n";
$body.="Content-Transfer-Encoding: ".$this->ctencoding."\r\n\r\n";
$body.=$text;
}
elseif (strlen($alternative_text) and $text_html == 'text/html')
{
$body = "Content-Type: multipart/alternative; boundary=ALT-".$this->boundary."\r\n\r\n";
$body.="--ALT-".$this->boundary."\r\n";
$body.="Content-Type: text/plain; charset=".$this->charset."\r\n";
$body.="Content-Transfer-Encoding: ".$this->ctencoding."\r\n\r\n";
$body.=$alternative_text."\r\n";
$body.="--ALT-".$this->boundary."\r\n";
$body.="Content-Type: text/html; charset=".$this->charset."\r\n";
$body.="Content-Transfer-Encoding: ".$this->ctencoding."\r\n\r\n";
$body.=$text."\r\n";
$body.="--ALT-".$this->boundary."--";
}
$this->SubBody[$resource]['body'][0] = $body;
}
protected function mime_content_type($file)
{
$ext = strtolower(substr(strrchr(basename($file), '.'), 1));
switch ($ext)
{
case 'jpg': return 'image/jpeg';
case 'jpeg': return 'image/jpeg';
case 'gif': return 'image/gif';
case 'png': return 'image/png';
case 'ico': return 'image/x-icon';
case 'txt': return 'text/plain';
default: return 'application/octet-stream';
}
}
public function Attach($filename, $new_name_filename = "", $filetype = "", $disposition = "", $resource = 'webi')
{
if (!strlen($resource))
$resource = 'webi';
if (!file_exists($filename))
{
return FALSE;
}
if (strlen($new_name_filename))
$basename = basename($new_name_filename);
else
$basename = basename($filename);
$charset_name = "=?".$this->charset."?B?".base64_encode($basename)."?=";
if (!strlen($filetype))
$filetype = $this->mime_content_type($basename);
$body = "Content-Type: ".$filetype."; name=\"$charset_name\"\r\n";
$body.="Content-Transfer-Encoding: base64\r\n";
if ($disposition == 'attachment')
{
$body.="Content-Disposition: attachment; filename=\"$charset_name\"\r\n";
}
$body.="Content-ID: <".$basename.">\r\n";
$body.="\r\n";
$body.=chunk_split(base64_encode(file_get_contents($filename)));
if ($disposition == 'attachment')
$this->SubBody[$resource]['mixed'][] = $body;
else
{
$this->SubBody[$resource]['body'][$this->count_body] = $body;
$this->count_body++;
}
}
public function BuildMail($resource = 'webi')
{
if (!strlen($resource))
$resource = 'webi';
$this->ready_headers[$resource] = '';
if (isset($this->SubBody[$resource]['body']))
$resource_body = $resource;
else
$resource_body = 'webi';
if (!is_array($this->sendto[$resource]) OR !count($this->sendto[$resource]))
{
$this->status_mail['status'] = false;
$this->status_mail['message'] = "Error : no recipient selected for ".$resource;
// return false;
}
if (!isset($this->body[$resource_body]))
{
if (count($this->SubBody[$resource_body]['body']) > 1)
{
$body = implode("\r\n--REL-".$this->boundary."\r\n", $this->SubBody[$resource_body]['body']);
$body = "Content-Type: multipart/related; boundary=REL-".$this->boundary."\r\n\r\n"
.'--REL-'.$this->boundary."\r\n".$body.'--REL-'.$this->boundary."--";
}
else
{
$body = $this->SubBody[$resource_body]['body'][0];
}
if (isset($this->SubBody[$resource_body]['mixed']) AND count($this->SubBody[$resource_body]['mixed']))
{
$bodymix = implode('--MIX-'.$this->boundary."\r\n", $this->SubBody[$resource_body]['mixed']);
$body = $body."\r\n--MIX-".$this->boundary."\r\n".$bodymix;
$body = "Content-Type: multipart/mixed; boundary=MIX-".$this->boundary."\r\n\r\n"
.'--MIX-'.$this->boundary."\r\n".$body.'--MIX-'.$this->boundary."--";
}
unset($this->SubBody[$resource_body]);
$temp_mass = explode("\r\n\r\n", $body);
$this->body_header[$resource_body] = $temp_mass[0];
unset($temp_mass[0]);
$this->body[$resource_body] = implode("\r\n\r\n", $temp_mass);
unset($temp_mass);
unset($body);
}
$temp_mass = array();
foreach ($this->sendto[$resource] as $key => $value)
{
if (strlen($this->names_email[$resource]['To'][$value]))
$temp_mass[] = "=?".$this->charset."?Q?".str_replace("+", "_", str_replace("%", "=", urlencode(strtr($this->names_email[$resource]['To'][$value], "\r\n", " "))))."?= <".$value.">";
else
$temp_mass[] = $value;
}
$this->headers[$resource]['To'] = implode(", ", $temp_mass);
if (isset($this->acc[$resource]) and count($this->acc[$resource]) > 0)
$this->headers[$resource]['CC'] = implode(", ", $this->acc[$resource]);
if (isset($this->abcc[$resource]) and count($this->abcc[$resource]) > 0)
$this->headers[$resource]['BCC'] = implode(", ", $this->abcc[$resource]);
if ($this->receipt)
{
if (isset($this->headers["Reply-To"]))
$this->headers["Disposition-Notification-To"] = $this->headers["Reply-To"];
else
$this->headers["Disposition-Notification-To"] = $this->headers['From'];
}
if ($this->charset != "")
{
$this->headers["Mime
没有合适的资源?快使用搜索试试~ 我知道了~
灰色简洁大气宽屏小清新扁平化美食美味食品西餐餐厅整站企业线条精品商务公司鲜花展示案例响应式手机中餐餐饮.rar
共95个文件
jpg:34个
js:18个
png:10个
需积分: 0 0 下载量 31 浏览量
2023-09-09
13:51:08
上传
评论
收藏 4.72MB RAR 举报
温馨提示
html模板
资源推荐
资源详情
资源评论
收起资源包目录
非常简洁大气西式餐厅整站企业模板_灰色简洁大气宽屏小清新扁平化美食美味食品西餐餐厅整站企业线条精品商务公司鲜花展示案例响应式手机中餐餐饮.rar (95个子文件)
page2_img3.jpg 58KB
page4_img6.jpg 20KB
style.css 15KB
superfish.css 3KB
index-1.html 9KB
page4_img4.jpg 14KB
Preloader_4.gif 17KB
bbig3.jpg 278KB
magnify.png 2KB
bbig7.jpg 302KB
page1_img1.jpg 49KB
totop.png 3KB
bbig5.jpg 376KB
PIE.php 613B
big2.jpg 267KB
regula.js 25KB
page4_img1.jpg 74KB
FontAwesome.otf 61KB
PIE.htc 40KB
TMForm.js 44KB
booking.css 9KB
page1_img4.jpg 44KB
big1.jpg 76KB
page2_img4.jpg 57KB
page3_img1.jpg 53KB
fontawesome-webfont.eot 37KB
big3.jpg 277KB
icon1.png 2KB
stuck.css 914B
logo.png 3KB
icomoon.woff 67KB
page2_img5.jpg 73KB
icomoon.svg 224KB
font-awesome.css 21KB
page1_img3.jpg 56KB
modal.js 7KB
page2_img7.jpg 55KB
bbig8.jpg 321KB
fontawesome-webfont.woff 43KB
icomoon.dev.svg 236KB
bbig9.jpg 252KB
page4_img5.jpg 18KB
mixins.less 21KB
index-3.html 11KB
index-4.html 8KB
quotes.png 1KB
booking.js 12KB
icomoon.eot 44KB
booking.less 5KB
page1_img2.jpg 32KB
html5shiv.js 2KB
bbig1.jpg 94KB
bbig6.jpg 367KB
superfish.js 7KB
page1_img5.jpg 44KB
arrowws.png 2KB
bann_sep.png 1KB
index-2.html 8KB
index.html 10KB
form.css 8KB
page2_img8.jpg 54KB
page4_img2.jpg 93KB
bbig4.jpg 311KB
page1_img7.jpg 7KB
MailHandler.php 2KB
fontawesome-webfont.svg 197KB
marker.png 1KB
tmStickUp.js 2KB
icon3.png 2KB
page2_img6.jpg 82KB
jquery.mobilemenu.js 2KB
fontawesome-webfont.ttf 79KB
jquery.easing.1.3.js 8KB
page2_img2.jpg 65KB
jquery.equalheights.js 1KB
jquery.js 91KB
grid.css 6KB
preloader.gif 3KB
jquery-ui-1.10.3.custom.min.js 39KB
ie.css 359B
touchTouch.css 2KB
touchTouch.jquery.js 6KB
jquery.fancyform.js 40KB
booking.php 750B
jquery-migrate-1.1.1.js 17KB
page2_img1.jpg 53KB
jquery.placeholder.js 5KB
icomoon.ttf 44KB
page2_img9.jpg 41KB
jquery.ui.totop.js 2KB
libmail.php 28KB
page4_img3.jpg 98KB
script.js 1KB
page1_img6.jpg 46KB
icon2.png 2KB
共 95 条
- 1
资源评论
Q_97095639
- 粉丝: 365
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功