下面是我写的NT下的用PHP 发MAIL的函数. 供参考
function wmail( $smtpserver="smtp.163.com",$to, $subject, $message, $from = "cnhis@163.com", $content_type = "text/plain", $attache=""){
$fp = fsockopen($smtpserver, 25, &$errno, &$errstr, 10);
if(!$fp) return(False);
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"220")) return(False);
$smailname=strstr(ltrim($hostreplay),"220 ") ;
$smailname=substr($smailname,0,strpos($smailname,".")) ;
fputs($fp,"HELO $smailname /n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) return(False);
fputs($fp,"MAIL FROM: /n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) {
fputs($fp,"MAIL FROM: root/n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) {
fputs($fp,"MAIL FROM: root@163.com/n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) {
fputs($fp,"MAIL FROM: $from/n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) return(False);
};
};
};
fputs($fp,"RCPT TO: $to/n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) {
fputs($fp,"RCPT TO: $subject/n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) return(False);
};
fputs($fp,"DATA/n") ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"354")) return(False);
$tosend="From: $from/n";
$tosend.="To: $to/n";
$tosend.="Subject:".str_replace("/N"," ",$subject)."/n$message/n./n";
fputs($fp,$tosend) ;
$hostreplay=fgets($fp,128);
if (!strstr($hostreplay,"250")) return(False);
fputs($fp,"QUIT/n") ;
fclose($fp) ;
if($ck_name!='root') return(True);
}