繁体中文
设为首页
加入收藏
当前位置:PHP技术首页 >> PHP基础 >> NT下基于邮件服务软件(IMAIL)的邮件发送程序--(网络版)

NT下基于邮件服务软件(IMAIL)的邮件发送程序--(网络版)

2004-12-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:如果你无法在服务器上安装IMAIL,那只能通过socket来发送邮件。但是如果你幸运的话,也可以用163/sina的 smtp服务。 例程如下(原程序由马毅兄提供): Mail Form anywhere

如果你无法在服务器上安装IMAIL,那只能通过socket来发送邮件。但是如果你幸运的话,也可以用163/sina的

smtp服务。

例程如下(原程序由马毅兄提供):

Mail Form anywhere

if($sendit)

{

$smtpserver="202.110.200.242" ; //将此处设为IMAIL的IP

echo "

" ;

$fp = fsockopen($smtpserver, 25, &$errno, &$errstr, 10) ; //连接smtp服务器,端口25

if(!$fp) die("wrong open smtp SERVER") ;

$hostreplay=fgets($fp,128);

//if (!strstr($hostreplay,"220")) die(" can n't receive the 220 answer ") ;

$smailname=strstr(ltrim($hostreplay),"220 ") ;

$smailname=substr($smailname,0,strpos($smailname,".")) ;

//echo "\nsmailname:$smailname\n" ;

fputs($fp,"$smailname \n") ;

$hostreplay=fgets($fp,128);

//if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;

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@263.net\n") ;

echo($hostreplay=fgets($fp,128)) ;

if (!strstr($hostreplay,"250")) {

fputs($fp,"MAIL FROM: $from_address\n") ;

$hostreplay=fgets($fp,128) ;

if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;

};

};

};

fputs($fp,"RCPT TO: $to_address\n") ;

$hostreplay=fgets($fp,128);

if (!strstr($hostreplay,"250")) {

fputs($fp,"RCPT TO: $mailname\n") ;

$hostreplay=fgets($fp,128) ;

if (!strstr($hostreplay,"250")) echo(" can n't receive the 354 answer") ;

};

fputs($fp,"DATA\n") ;

$hostreplay=fgets($fp,128) ;

if (!strstr($hostreplay,"354")) die(" can n't receive the 250 answer ") ;

$tosend="From: $from_address\n";

$tosend.="To: $to_address\n";

$tosend.="Subject:".str_replace("\N"," ",$subject)."\n你好,这是yukuang发给您的一封测试信!!

\n.\n";

fputs($fp,$tosend) ;

$hostreplay=fgets($fp,128) ;

if (!strstr($hostreplay,"250")) die(" can n't receive the 250 answer ") ;

fputs($fp,"QUIT\n") ;

fclose($fp) ;

echo "发送成功";

exit();

//if($ck_name!='root') die("


bye bye ");

};

?>


cn-bbs web meil

from

value="">

to

value="">

subject

c

o

n

t

e

n

t


该程序在局域网内调试通过,我的IP是202.110.200.242,供大家测试

责任编辑:admin
相关文章