我正在使用 Actionscript 3.0 并正在制作一个网站!
在我的网站中,我想制作一个按钮,通过单击按钮发送电子邮件,但我不希望它打开他们的邮件客户端,而只是发送电子邮件。
我目前正在使用“mailto”功能,但想知道如何使其自动发送,或者我还可以使用什么来实现这一点。
这是我的代码片段:
function submitPoll(e:MouseEvent):void {
//sending the email stuff
var request:URLRequest = new URLRequest("mailto:[email protected] /cdn-cgi/l/email-protection"+"?subject=Subject"+"&body= Hello world ");
navigateToURL(request, "_blank");
request.method = URLRequestMethod.POST;
//other
Submit_btn.x = -100;
pollUsed = true;
thanks_txt.x = 849;
thanks_txt.y = 656;
}
在发送电子邮件方面,Flash 的情况与 HTML 的情况大致相同。您有 2 个选择:
- 使用以下命令在用户计算机上弹出电子邮件客户端
mailto
就像你正在做的那样。
- Send a
POST
or GET
向可以代表您发送电子邮件的服务器发出请求。
您想要做的是第 2 项,这意味着您需要访问能够发送邮件且能够接收邮件的服务器GET/POST
要求。如果您可以访问网络服务器的脚本,那么您无疑可以找到一个免费的在线脚本来发送电子邮件。例如:
- PHP http://www.google.com/search?q=email%20script%20php
- Python http://www.google.com/search?q=email%20script%20python
- Ruby http://www.google.com/search?q=email%20script%20ruby
- Perl http://www.google.com/search?q=email%20script%20perl
- ASP http://www.google.com/search?q=email%20script%20asp
如何将信息发送到脚本将取决于脚本要求您发送哪些变量。在 ActionScript 中,您可能会想要使用网址加载器 http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLLoader.html:
const SCRIPT_URL:String = "http:// .... your server ... / ... script file ...";
var request:URLRequest = new URLRequest(SCRIPT_URL);
var variables:URLVariables = new URLVariables();
// these depend on what names the script expects
variables.email = "[email protected] /cdn-cgi/l/email-protection";
variables.subject = "Subject";
variables.body = "Hello World";
request.data = variables;
// depends if the script uses POST or GET
// adjust accordingly
request.method = URLRequestMethod.POST;
var urlLoader:URLLoader = new URLLoader();
loader.load(request);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)