当前位置: 首页 > 图文教程 > 网络编程 > PHP > PHP下MAIL的另一解决方案

PHP
PHP新手总结的PHP基础知识
php实现gb2312和unicode间编码转换
用php语言实现数据库连接详细代码介绍
详细解析 PHP 向 MySQL 发送数据过程
利用PHP V5开发多任务应用程序
详细讲解PHP中缓存技术的应用
php escapeshellcmd多字节编码漏洞
《PHP设计模式介绍》导言
《PHP设计模式介绍》第一章 编程惯用法
《PHP设计模式介绍》第二章 值对象模式
《PHP设计模式介绍》第三章 工厂模式
《PHP设计模式介绍》第四章 单件模式
《PHP设计模式介绍》第五章 注册模式
《PHP设计模式介绍》第六章 伪对象模式
《PHP设计模式介绍》第七章 策略模式
《PHP设计模式介绍》第八章 迭代器模式
《PHP设计模式介绍》第九章 观测模式
《PHP设计模式介绍》第十章 规范模式
《PHP设计模式介绍》第十一章 代理模式
《PHP设计模式介绍》第十二章 装饰器模式

PHP下MAIL的另一解决方案


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 268 ::
收藏到网摘: n/a

前一段时间我接触到DECTru64Unix我在上面装了PHP+APACHE,可以用提供的mail函数始终不能正常发信,于是自编了一个函数,它利用UNIX下的管道和PHP的SOCK函数进行发信,经过实验非常驻成功,下面是此函数原代码。
functionmymail($mto,$mcc,$msubject,$mbody)
{
$from="[email protected]";
$sign="";//随你便写些什么
$sendmailpath="/usr/lib/sendmail";//Semdmail路径
$bound="========_".uniqid("BCFMail")."==_";//分界符
$headers="MIME-Version:1.0".
"Content-Type:multipart/mixed;boundary="$bound"".
"Date:".date("D,dMH:i:sY")."".
"From:$from".
"To:$mto".
"Cc:$mcc".
"Subject:$msubject".
"Status:".
"X-Status:".
"X-Mailer:MYEmailInterface".
"X-Keywords:";
$content="--".$bound.""."Content-Type:text/plain;charset="GB2312"".$mbody.$sign."";
$end=""."--".$bound."--";
$sock=popen("$sendmailpath-t-f'[email protected]'",'w');
fputs($sock,$headers);
fputs($sock,$content);
fputs($sock,$end);
fputs($sock,".");
fputs($sock,"QUIT");
pclose($sock);
}