资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 编程开发 >
Advertisement
文章正文

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

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   
  • 程序设计之道 
  • 加入了phpCVSView项目 
  • 突然发现CVSTrac 
  • Subversion和Berkeley DB 
  • 古代最成功的项目管理案例 [转贴] 
  • “八正道”管理方案 
  • 需求分析检查表 
  • 小软件项目开发的管理(zt) 
  • UI界面设计——界面设计不存在美工 
  • 对CMM的认识 
  • 页面导航:

    正文内容:
    如果你无法在服务器上安装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 nt 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 nt 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 nt 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 nt receive the 354 answer") ;
    };
    fputs($fp,"data\n") ;
    $hostreplay=fgets($fp,128) ;
    if (!strstr($hostreplay,"354")) die(" can nt 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 nt 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,供大家测试

     

     
    热门推荐笔记本: 七喜笔记本
    相关文章:
    webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
    ©2007 popbb.net All Rights Reserved