首 页WAP教程WAP源码WAP电子书客户留言龙腾电脑维修网158网络电视本站论坛繁體中文
设为首页
加入收藏
联系我们
您当前的位置:WAP开发网 -> WAP教程 -> WML教程 -> 文章内容 退出登录 用户管理
栏目导航
· ASP WAP开发教程 · ASP.net WAP开发教程
· PHP WAP开发教程 · WML教程
· JSP开发WAP教程 · WAP 2.0
· 综合杂谈
热门文章
· WAP 2.0教程
· WML语言基础(WAP建站...
· 用VS2005实现ASP.NE...
· [组图] php WAp开发教程
· WML语言基础(WAP建站...
· VS.NET 2003开发移动...
· [图文] ASP技术进行动态WAP...
· [图文] WML语言基础(WAP建站...
· asp.net移动控件开发...
· [图文] 创建移动Web应用程序...
相关文章
· asp.net强制输出WML...
· WML初级教程之关于W...
· 使用WML和ASP编写动...
· [推荐] 如何链接WML和XHTML...
· WAP初级教程----WML...
· WAP初级教程---WML基...
· PHP建立动态的WML站...
· wml如何实现下载图片...
· WML语言全垒打
· 可以通过WML使得可以...
如何使用WAP设备发送E-Mail
作者:不详  来源:本站整理  发布时间:2006-5-16 10:49:37  发布人:tangyunfei

减小字体 增大字体


在HTML中有一个默认的E-Mail机制:“ mailt” 。但在WML中不好使,因此E-Mails必须通过WML表单来解决。例如:
<wml>
     <card id="edit" title="Email Editor">
      <p>From: <input type="text" name="from" format="*M"/></p>
      <p>T <input type="text" name="to" format="*M"/></p>
      <p>Subject: <input type="text" name="subject" format="*M"/></p>
      <p>Message body: <input type="text" name="body" format="*M"/></p>
      <p>
        <anchor>Send this mail
          <go method="post" href="http://some.host/mailhandler"?action=send/">
            <postfield name="from" value="$(from)"/>
            <postfield name="to" value="$(to)"/>
            <postfield name="subject" value="$(subject)"/>
            <postfield name="body" value="$(body)"/>
          </go>
       </anchor>
      </p>
   </card>
</wml> 
    在代码中的http://some.host/mailhandler是一个CGI程序,它是服务端的脚本程序,将提交的表单转换成E-Mail格式并发送出去。
    如果想使用一个类似于发信的过程,就需要编辑变量名。另外发送的数据是有限的,长信息可能需要打断。
    为了演示它是如何工作的,下面的 PHP 脚本可以用来处理Mail。它将格式化WML页面,告诉用户是否发出信件。在真实的应用中,应该加入检测,例如:E-Mail的合法格式。
<?
// Tell the client that this is a WML deck
    header("Content-type: text/vnd.wap.wml");
    echo("<?xml version=\"1.0\"?>\n");
    echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
// The name of your mail server
    $mailer = "wap.colorline.no";
// Format the from field
    $from = $from." (WAP user at ".$mailer.")";
// Add the from field and some character handling to the extra headers
  $extraheaders = $from."\nContent-Type: text/plain;
charset=iso-8859-1\nContent-Transfer-Encoding: 8bit";
// Start sending out the WML deck
    echo("<wml>\n");
    if(mail($to,$subject,$body,$extraheaders))
{// Use PHP's internal mail functionality
// Mail was successfully sent
      echo("<card id=\"sent\" title=\"Mail sent\">\n");
      echo("<p>Mail was sent successfully</p>\n");
      echo("</card>\n");
    }
    else {
// The mail could not be sent
      echo("<card id=\"notsent\" title=\"Mail failed\">\n"); 
      echo("<p>Unable to send mail</p>\n");
      echo("</card>\n");
    }
    echo("</wml>\n");
?>
    因为安全性的原因,以上的代码没有演示程序。
[] [返回上一页] [打 印] [收 藏]
下一篇文章:WAP协议初级读本
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 管理登录
Copyright © 2002-2005 wapkf.com. All Rights Reserved .
浙ICP备06013604号|站长QQ:274273595