后端开发|php教程
,邮件,可以,附件,格式,发送,例子,message,nam
后端开发-php教程
这有个例子:
论坛源码 ,vscode+文件对比工具,ubuntu捷豹,tomcat公开路径,akamai爬虫管理,php上传文件不成功,西安seo整合营销推广,医院导航网站源码,页面模板下载lzw
/*
* Class mime_mail
* Original implementation by Sascha Schumann
* Modified by Tobias Ratschiller :
*– General code clean-up
*– separate body- and from-property
*– killed some mostly un-necessary stuff
*/
易语言微信拦截接收消息源码,ubuntu源码安装cgdb,付费文章的爬虫,php 生成整数,seo 排名靠前lzw
class mime_mail
{
var $parts;
var $to;
var $from;
var $headers;
var $subject;
var $body;
java写的qq监控程序源码,vscode扩展商店不见了,ubuntu vim美化,tomcat速度拖得很慢,爬虫亚洲观察,php 输出对象信息,自己做seo推广需要钱么lzw
/*
*void mime_mail()
*class constructor
*/
function mime_mail()
{
$this->parts = array();
$this->to = “”;
$this->from = “”;
$this->subject = “”;
$this->body = “”;
$this->headers = “”;
}
/*
*void add_attachment(string message, [string name], [string ctype])
*Add an attachment to the mail object
*/
function add_attachment($message, $name = “”, $ctype =
“application/octet-stream”)
{
$this->parts[] = array (
“ctype” => $ctype,
“message” => $message,
“encode” => $encode,
“name” => $name
);
}
/*
*void build_message(array part=
*Build message parts of an multipart mail
*/
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”.
“\nContent-Disposition: inline”.
($part[“name”]?”; filename=\””.$part[“name”].”\””:””).
“\n\n$message\n”;
}
/*
*void build_multipart()
*Build a multipart mail
*/
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”;
}
/*
*void send()
*Send the mail (last class-function to be called)
*/
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
/*
* Example usage
*
$attachment = fread(fopen(“test.jpg”, “r”), filesize(“test.jpg”));
$mail = new mime_mail();
$mail->from = “foo@”;
$mail->headers = “Errors-To: foo@”;
$mail->to = “bar@”;
$mail->subject = “Testing…”;
$mail->body = “This is just a test.”;
$mail->add_attachment(“$attachment”, “test.jpg”, “image/jpeg”);
$mail->send();
*/
?>