本文作者曾經接觸到DECTru64Unix,并在上面裝了PHP+APACHE,可以用提供的mail函數始終不能正常發信,于是作者自編了一個函數,它利用UNIX下的管道和PHP的SOCK函數進行發信,經過實驗非常駐成功。
下面是此函數原代碼。
functionmymail($mto,$mcc,$msubject,$mbody)
{
$from="webmaster@backhome.com.cn";
$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'webmaster@backhome.com.cn'",'w');
fputs($sock,$headers);
fputs($sock,$content);
fputs($sock,$end);
fputs($sock,".");
fputs($sock,"QUIT");
pclose($sock);
}
新聞熱點
疑難解答