开源软件网
当前位置:文章首页 >> PHP Zend >> NT下基于邮件服务软件(IMAIL)的发送程序

NT下基于邮件服务软件(IMAIL)的发送程序
2008-04-22 23:08:10  作者:hauver  来源:互连网  浏览次数:0  网友评论0  文字大小:【】【】【】 评分等级:4

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

smtp服务。

例程如下(原程序由马毅兄提供):
<HTML>
<HEAD>
<TITLE>Mail Form anywhere </TITLE>
</HEAD>
<BODY>
<?
if($sendit)
{
$smtpserver="202.110.200.242" ;        //将此处设为IMAIL的IP
echo "<pre>" ;
$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("</pre><hr>bye bye ");

};

?>

<br>
<FORM METHOD="POST" ACTION=" <? echo $PHP_SELF; ?>" >
<table width="73%" border="1" align="center">
<tr>
<td colspan="5">
<div align="center">cn-bbs web meil </div>
</td>
</tr>
<tr>
<td width="9%">from<br>
</td>
<td width="36%">
<input type="text" name="from_address" size="30" maxlength="40"
value="">
</td>
<td width="6%">to </td>
<td colspan="2" width="49%">
<input type="text" name="to_address" size="40" maxlength="40"
value="">
</td>
</tr>
<tr>
<td width="9%">subject</td>
<td colspan="4">
<input type="text" name="subject" size="80" maxlength="200" value=" ">
</td>
</tr>
<tr>
<td rowspan="5" width="9%">c<br>
o<br>
n<br>
t<br>
e<br>
n<br>
t</td>
<td colspan="4" rowspan="5">
<div align="center">
<textarea name="message" cols="80" rows="16"> </textarea>
</div>
</td>
</tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr>
<td colspan="5" height="2">
<div align="center">
<select name="smtpserver">
<option value="smtp.21cn.com" selected>21cn.net</option>
<option value="smtp.163.net">163.com</option>
<option value="smtp.263.net">263.com</option>
<option value="server0026.freedom2surf.net">server0026.freedom2surf.net</option>
<option value="www.cnbbs.f2s.com" >www.cnbbs.f2s.com</option>
</select>
<input type=submit value ="ok . send" name="sendit">
<input type=reset value ="Reset " name="reset">
<input type="button" name="back" value="cancle" onclick=history.back()>
</div>
</td>
</tr>
</table>
<br>
</FORM>
</BODY>
</html>

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


本文引用地址:http://www.open-soft.com.cn/article/2008/0422/article_95.html

责任编辑:hauver

发表评论】 【加入收藏】 【告诉好友】 【打印本页】 【关闭窗口】 【返回顶部
相关评论 0条评论  发表/查看更多评论 
发表评论  【返回顶部】【关闭窗口】 
评分: 1 2 3 4 5

    
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。
 
FleaPHP -- 中国人自己的... [2008-07-18]
[推荐]用PHP实现POP3邮件的... [2008-04-22]
[注意]PHP功能齐全的发送... [2008-04-22]
[推荐]如何用PHP发电子邮... [2008-04-22]
PHP+MYSQL动态网页编程纠... [2008-04-21]
[注意]Apache+PHP+MySQL详细配... [2008-04-21]
[推荐]Linux上安装Oracle、... [2008-04-21]
利用Yahoo! Search API开发... [2008-04-21]
[推荐]五种常见的 PHP 设... [2008-04-21]
[推荐]五种常见的 PHP 设... [2008-04-21]