Home >Backend Development >PHP Tutorial >NT下基于邮件服务软件(IMAIL)的邮件发送程序--(网络版)_PHP
IMail
如果你无法在服务器上安装IMAIL,那只能通过socket来发送邮件。但是如果你幸运的话,也可以用163/sina的" ;<br> $fp = fsockopen($smtpserver, 25, &$errno, &$errstr, 10) ; //连接smtp服务器,端口25<br> if(!$fp) die("wrong open smtp SERVER") ;<br> $hostreplay=fgets($fp,128);<br> //if (!strstr($hostreplay,"220")) die(" can n't receive the 220 answer ") ;<br> $smailname=strstr(ltrim($hostreplay),"220 ") ;<br> $smailname=substr($smailname,0,strpos($smailname,".")) ;<br> //echo "\nsmailname:$smailname\n" ;<br> fputs($fp,"$smailname \n") ;<br> $hostreplay=fgets($fp,128);<br> //if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;<br> <br> fputs($fp,"MAIL FROM: \n") ;<br> $hostreplay=fgets($fp,128) ;<br> if (!strstr($hostreplay,"250")) {<br> fputs($fp,"MAIL FROM: root\n") ;<br> $hostreplay=fgets($fp,128) ;<br> if (!strstr($hostreplay,"250")) {<br> fputs($fp,"MAIL FROM: root@263.net\n") ;<br> echo($hostreplay=fgets($fp,128)) ;<br> if (!strstr($hostreplay,"250")) {<br> fputs($fp,"MAIL FROM: $from_address\n") ;<br> $hostreplay=fgets($fp,128) ;<br> if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;<br> };<br> };<br> };<br> fputs($fp,"RCPT TO: $to_address\n") ;<br> $hostreplay=fgets($fp,128);<br> if (!strstr($hostreplay,"250")) {<br> fputs($fp,"RCPT TO: $mailname\n") ;<br> $hostreplay=fgets($fp,128) ;<br> if (!strstr($hostreplay,"250")) echo(" can n't receive the 354 answer") ;<br> };<br> fputs($fp,"DATA\n") ;<br> $hostreplay=fgets($fp,128) ;<br> if (!strstr($hostreplay,"354")) die(" can n't receive the 250 answer ") ;<br> $tosend="From: $from_address\n";<br> $tosend.="To: $to_address\n";<br> $tosend.="Subject:".str_replace("\N"," ",$subject)."\n你好,这是yukuang发给您的一封测试信!!<br> <br> \n.\n";<br> fputs($fp,$tosend) ;<br> $hostreplay=fgets($fp,128) ;<br> if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;<br> fputs($fp,"QUIT\n") ;<br> fclose($fp) ;<br> echo "发送成功";<br> exit();<br> //if($ck_name!='root') die("