电话提交表格,如何发送到我的电子邮件 [英] phonegap submit form, how to send to my email

查看:138
本文介绍了电话提交表格,如何发送到我的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用简单的输入字段(名称,姓氏,问题)制作简单的html表单。
我希望当用户填写输入字段(名称,姓氏,问题)并点击提交发送到我的电子邮件地址。



您是否有任何想法如何用phonegap做到这一点?



谢谢

解决方案

您可以使用 Cordova EmailComposer Plugin 强>。点击提交按钮后添加此功能。要安装,请按照以下步骤操作。



https://github.com/katzer/cordova-plugin-email-composer

  function emailComposer(){ 

window.plugin.email.isServiceAvailable(
函数(isAvailable){
if(isAvailable){
window.plugin.email.open({
to:[''],
cc:[''],
bcc:[''],
主题:'',
body:''
});
} else {
alert('Service is not available');
}
}
);



$ b ** JQUERY - 调用PHP脚本来发布数据**

var ajax_call = serviceURL;
var form_data = $('#form')。serialize();
$ .ajax({
type:POST,
url:ajax_call,
data:form_data,
dataType:json,
成功:函数(响应){
//成功时调用

},
错误:函数(e){
//出错时调用
//console.log(e.message);
}
});

示例


I am building simple phonegap android app.

i make simple html form with few input fields (Name, Last name, Question). I want that when user fill input fields (Name, Last name, Question) and click Submit to send to my email address. Just that.

Do you have any idea how to do that with phonegap?

Thank you

解决方案

You can do using Cordova EmailComposer Plugin for Android . Add this function on your submit button click. For installation follow these steps .

https://github.com/katzer/cordova-plugin-email-composer

function emailComposer(){    

  window.plugin.email.isServiceAvailable(
    function (isAvailable) {
      if(isAvailable){
            window.plugin.email.open({
                to:      [''],
                cc:      [''],
                bcc:     [''],
                subject: '',
                body:    ''
            });         
      }else{
          alert('Service is not available');
      }
    }
  );

}


**JQUERY - CALL PHP SCRIPT TO POST DATA**  

var ajax_call = serviceURL;
var form_data = $('#form').serialize();
$.ajax({
   type: "POST",
   url: ajax_call,
   data: form_data,
   dataType: "json",
   success: function(response) {
    //called when successful

   },
   error: function(e) {
      //called when there is an error
   //console.log(e.message);
   }
});

Examples

这篇关于电话提交表格,如何发送到我的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆