文章詳情頁
PHP下MAIL的另一解決方案
瀏覽:10日期:2024-01-08 08:38:57
前一段時間我接觸到DEC Tru64 Unix 我在上面裝了PHP+APACHE,可以用提供的mail函數(shù)始終不能正常發(fā)信,于是自編了一個函數(shù),它利用UNIX下的管道和PHP的SOCK函數(shù)進行發(fā)信,經(jīng)過實驗非常駐成功,下面是此函數(shù)原代碼。 function mymail($mto,$mcc,$msubject,$mbody) {;;$from="[email protected]"$sign = "n";//隨你便寫些什么 $sendmailpath="/usr/lib/sendmail";//Semdmail路徑 $bound = "========_".uniqid("BCFMail")."==_";//分界符 ;;$headers =;;"MIME-Version: 1.0n". ;;;;"Content-Type: multipart/mixed; boundary="$bound"n". ;;;;"Date: ".date("D, d M H:i:s Y ")."n". ;;;;"From: $fromn". ;;;;"To: $mton". ;;;;"Cc: $mccn". ;;;;"Subject: $msubjectn". ;;;;"Status: n". ;;;;"X-Status:n". ;;;;"X-Mailer: MY Email Interfacen". ;;;;"X-Keywords:nn";$content="--".$bound."n"."Content-Type:text/plain;charset="GB2312"nn".$mbody.$sign."n";$end = "n"."--".$bound."--n";$sock = popen("$sendmailpath -t -f '[email protected]'",'w'); ;;fputs($sock, $headers); ;;fputs($sock, $content); ;;fputs($sock, $end); ;;fputs($sock, ".n"); ;;fputs($sock, "QUITn"); ;;pclose($sock); };
標簽:
PHP
排行榜
