Home  >  Article  >  Backend Development  >  Another solution to MAIL under PHP_PHP Tutorial

Another solution to MAIL under PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 16:06:01928browse

Some time ago, I came into contact with DEC Tru64 Unix. I installed PHP+APACHE on it. I could use the provided mail function but could not send mail normally, so I wrote a function myself, which uses the pipe under UNIX and the SOCK function of PHP to send mail. Xin, the experiment was non-resident and successful. The following is the original code of this function.
function mymail($mto,$mcc,$msubject,$mbody)
{
$from="webmaster@backhome.com.cn";
$sign = "n";// Write whatever you want
$sendmailpath="/usr/lib/sendmail";//Semdmail path
$bound = "========_".uniqid("BCFMail"). "==_"; // Delimiter
$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 'webmaster@backhome.com.cn' ",'w');
fputs($sock, $headers);
fputs($sock, $content);
fputs($sock, $end);
fputs($sock , ".n");
fputs($sock, "QUITn");
pclose($sock);
}

http://www.bkjia.com/PHPjc/315565.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315565.htmlTechArticleSome time ago I came into contact with DEC Tru64 Unix. I installed PHP+APACHE on it and can use the provided mail function. I still couldn't send a message normally, so I wrote a function, which uses pipes and...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn