当前位置:首页 > 设计在线 > 网页设计 > CSS/Xhtml > 使用WAP设备发送E-Mail-wap发送邮件

使用WAP设备发送E-Mail-wap发送邮件

点击次数:38 次 发布日期:2008-11-21 16:04:11 作者:源代码网
源代码网推荐

源代码网整理以下在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"?> ");
    echo("<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml"> ");
// 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." Content-Type: text/plain;
charset=iso-8859-1 Content-Transfer-Encoding: 8bit";
// Start sending out the WML deck
    echo("<wml> ");
    if(mail($to,$subject,$body,$extraheaders))
{// Use PHP"s internal mail functionality
// Mail was successfully sent
      echo("<card id="sent" title="Mail sent"> ");
      echo("<p>Mail was sent successfully</p> ");
      echo("</card> ");
    }
    else {
// The mail could not be sent
      echo("<card id="notsent" title="Mail failed"> "); 
      echo("<p>Unable to send mail</p> ");
      echo("</card> ");
    }
    echo("</wml> ");

源代码网整理以下?>


因为安全性的原因,以上的代码没有演示程序。 源代码网供稿.
网友评论 (0)
会员中心
设计在线
本站推荐
设计在线之精华