您现在的位置是:首页 >

小程序开发公司 如何用Delphi开发简单的WebMail程序

火烧 2021-12-08 17:36:06 1053
如何用Del hi开发简单的We Mail程序 We Mail是指在网页中实现邮件的发送 使用Del hi开发We Server程序是非常简单的 Del hi中提供了大量的元件和对象 下面通过一个例子

如何用Delphi开发简单的WebMail程序  

WebMail是指在网页中实现邮件的发送 使用Delphi开发Web Server程序是非常简单的 Delphi中提供了大量的元件和对象 下面通过一个例子来介绍如何利用Delphi开发一个响应用户输入的ISAPI的WebMail程序 为了简单 程序没有对传送的数据提供保密

  首先 在Web服务器端安装数据库引擎dbe 并设置好数据库别名 yh 指向一个包含用户名和用户密码的数据库文件user db 接着建立两个HTML文件 名字分别为 dl qd 放在Web服务器的缺省目录下(如 c \inetpub\root)

  dl 的内容如下

    <>    <head><title>发送邮件系统</title></head>    <body>    <h >发送邮件系统</h >        <p>请输入您的用户名及密码</p>    <form method= post action= /scripts/SendMail >    <p>用户名<input type= text length= name= username >    密码 < input type= password length= name= password ></p>        <p><input type= submit value= 确定 >    <input type= reset value= 清除 ></p>    </form>    </body>    </>   qd 文件内容如下

    <><head><title>填表</title></head>    <body>    <form method= post action= feedback >    <p>请填入接收邮件地址:toaddress:    <input type= text length= name= toaddress ></p>    <p>请填入主题<input type= text length= name= subject ></p>    <p>内容 </p>    <p><input type= textarea length= width= name= body ></p>    <p><input type= submit value= 确定 >    <input type= reset value= 清除 ></p>    </form >    </body >    </ >   在Delphi中新建一个基于ISAPI的Web Server Application 手动增加nmsmtp query pageproducer 其中 pageproducer 的file属性为c:\inetpub\ root\qd nmsmtp 的host(发送邮件服务器的地址)在这里为smtp netease port: 全局变量为 sername:string;flag:boolean

小程序开发公司 如何用Delphi开发简单的WebMail程序

  增加一个路径为feedback的动作项 其代码如下

     Var     Count:integer;    S:string;     Begin    Query close;    Query sql clear;        S:= select count(username) from user dbswheresusername= ;    S:=s+request contentfields values[ username ]+ ;    S:=s+ and password= ;    S:=s+request contentfields values[ psword ]+ ;    Query sql add(S);    Query open;    If query count= then response content:=     <><head><title>    </title>    <body>用户名 密码不正确 请重新输入</body>    </>     Else     Username:=request contentfields values[ username ];    Response content:=pageproducer content;    End;   再增加一个路径为Sendmail的动作项 它的程序代码如下

    Var body:string;    Begin    Flag:=true;    body:=request contentfields values[ body ];    Pageproducer doc clear;    Pageproducer doc add( < >< body > );    Nmsmtp postmessage clear;    Nmsmtp postmessage fromaddress:=username+ @netease ;    Nmsmtp postmessage from:=username;    Nmsmtp postmessage body add(body);    Nmsmtp postmessage toaddress add(request contentfields values[ toaddress ]);    Nmsmtp postmessage subject:=request contentfields values[ subject ]     Nmsmtp connect;    If flag=true then     begin    Nmsmtp sendmail;    nmsmtp disconntent;    end    pageproducer doc add( </body></> );    response content:=pageproducer content;    end;   增加nmsmtp 的OnConnect事件添加如下代码

lishixinzhi/Article/program/Delphi/201311/24974  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码