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

PHP
《PHP设计模式介绍》第十三章 适配器模式
《PHP设计模式介绍》第十四章 动态记录模式
《PHP设计模式介绍》第十五章 表数据网关模式
《PHP设计模式介绍》第十六章 数据映射模式
《PHP设计模式介绍》第十七章 MVC 模式
Zend Framework 入门——快速上手
Zend Framework 入门——多国语言支持
Zend Framework 入门——错误处理
Zend Framework 入门——页面布局
详细介绍php5编程中的异常处理
PHP5 OOP编程中的代理与异常
PHP程序的常见漏洞攻击分析
PHP.MVC的模板标签系统
PHP教程:PHP编码书写规范
PHP开发大型项目的方法:OOP思想
php使用curl模拟用户登陆
php对gb编码动态转utf-8编码的几种方法评测
php设计模式介绍之章代理模式
“在phpMyAdmin使用用户口令登陆”补充
PHP入门速成

PHP下MAIL的另一解决方案


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 63 ::
收藏到网摘: 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);
}