仓酷云

标题: PHP网站制作之我再来转载一篇 用EMAIL附件传送一个文... [打印本页]

作者: 第二个灵魂    时间: 2015-2-4 00:25
标题: PHP网站制作之我再来转载一篇 用EMAIL附件传送一个文...
基础这个东西,有人问学php需要任何基础不?   <?

/*
* Class mime_mail
* Original implementation by Sascha Schumann < sascha@schumann.cx >
* Modified by Tobias Ratschiller < tobias@dnet.it >:
* - General code clean-up
* - separate body- and from-property
* - killed some mostly un-necessary stuff
*/

class mime_mail
{
var $parts;
var $to;
var $from;
var $headers;
var $subject;
var $body;

/*
* 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\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@bar.com ";
$mail->headers = "Errors-To: foo@bar.com ";
$mail->to = " bar@foo.com ";
$mail->subject = "Testing...";
$mail->body = "This is just a test.";
$mail->add_attachment("$attachment", "test.jpg", "image/jpeg");
$mail->send();

*/
?>

  会HTML吗?会,我能编好几个大表格排板的网页啦!
作者: 精灵巫婆    时间: 2015-2-4 13:05
不禁又想起那些说php是草根语言的人,为什么认得差距这么大呢。
作者: 飘灵儿    时间: 2015-2-6 16:30
真正的方向了,如果将来要去开发团队,你一定要学好smarty ,phplib这样的模板引擎,
作者: 仓酷云    时间: 2015-2-6 16:53
如果你已经到这种程度了,那么你已经可以做我的老师了。其实php也分很多的区域,
作者: 谁可相欹    时间: 2015-2-10 01:30
Ps:以上纯属原创,如有雷同,纯属巧合
作者: 分手快乐    时间: 2015-2-10 09:19
为了以后维护的方便最好是代码上都加上注释,“予人方便,自己方便”。此外开发文档什么的最好都弄齐全。我觉得这是程序员必备的素质。虽然会消耗点很多的时间。但是确实是非常有必要的。
作者: 海妖    时间: 2015-2-12 18:40
因为blog这样的可以让你接触更多要学的知识,可以接触用到类,模板,js ,ajax
作者: 透明    时间: 2015-2-22 19:57
,熟悉html,能用div+css,还有javascript,优先考虑linux。我在开始学习的时候,就想把这些知识一起学习,我天真的认为同时学习能够互相呼应,因为知识是相通的。
作者: 小魔女    时间: 2015-2-27 04:01
最后介绍一个代码出错,但是老找不到错误方法,就是 go to wc (囧),出去换换气没准回来就找到错误啦。
作者: 不帅    时间: 2015-3-6 09:32
个人呢觉得,配wamp 最容易漏的一步就是忘了把$PHP$目录下的libmysql.dll拷贝到windows系统目录的system32目录下,还有重启apache。
作者: 再现理想    时间: 2015-3-7 19:15
再就是混迹于论坛啦,咱们的phpchina的论坛就很强大,提出的问题一般都是有达人去解答的,以前的帖子也要多看看也能学到不少前辈们的经验。别的不错的论坛例如php100,javaeye也是很不错的。
作者: 因胸联盟    时间: 2015-3-13 04:10
php是动态网站开发的优秀语言,在学习的时候万万不能冒进。在系统的学习前,我认为不应该只是追求实现某种效果,因为即使你复制他人的代码调试成功,实现了你所期望的效果,你也不了解其中的原理。
作者: 莫相离    时间: 2015-3-20 12:26
使用 jquery 等js框架的时候,要随时注意浏览器的更新情况,不然很容易发生框架不能使用。
作者: 简单生活    时间: 2015-3-21 13:52
个人呢觉得,配wamp 最容易漏的一步就是忘了把$PHP$目录下的libmysql.dll拷贝到windows系统目录的system32目录下,还有重启apache。
作者: 爱飞    时间: 2015-3-24 00:53
有位前辈曾经跟我说过,phper 至少要掌握200个函数 编起程序来才能顺畅点,那些不熟悉的函数记不住也要一拿手册就能找到。所以建议新手们没事就看看php的手册(至少array函数和string函数是要记牢的)。
作者: 再见西城    时间: 2015-3-24 17:54
不禁又想起那些说php是草根语言的人,为什么认得差距这么大呢。
作者: 蒙在股里    时间: 2015-3-26 18:23
真正的方向了,如果将来要去开发团队,你一定要学好smarty ,phplib这样的模板引擎,
作者: 老尸    时间: 2015-3-31 23:22
其实没啥难的,多练习,练习写程序,真正的实践比看100遍都有用。不过要熟悉引擎
作者: 柔情似水    时间: 2015-4-3 04:31
刚开始安装php的时候,我图了个省事,把php的扩展全都打开啦(就是把php.ini 那一片 extension 前面的冒号全去掉啦),这样自然有好处,以后不用再需要什么功能再来打开。
作者: 小女巫    时间: 2015-4-6 01:11
做为1门年轻的语言,php一直很努力。
作者: 小妖女    时间: 2015-4-15 07:16
找到的的资料很多都是在论坛里的,需要注册,所以我一般没到一个论坛都注册一个id,所有的id都注册成一样的,这样下次再进来的时候就不用重复注册啦。当然有些论坛的某些资料是需要的付费的。




欢迎光临 仓酷云 (http://www.ckuyun.com/) Powered by Discuz! X3.2