前一段时间我接触到DEC Tru64 Unix。
我在上面安装了PHP+APACHE,可是用提供的mail函数始终不能正常发信。
于是自已编了一个函数,它利用UNIX下的管道和PHP的SOCK函数进行发信。
经过实验非常驻成功,下面是此函数原代码。
function mymail($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, d M H:i:s Y ")." ".
"From: $from ".
"To: $mto ".
"Cc: $mcc ".
"Subject: $msubject ".
"Status: ".
"X-Status: ".
"X-Mailer: MY Email Interface ".
"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);
}
|