Harsh
Harsh

Reputation: 159

Sending Email using mobile application

I want to send email to [email protected] from my jQuery mobile app which is a phonegap project.how it is possible using ajax,js and jQuery mobile?? I want to implement 'feedback' function using this.User should able send title(Product name) and body(feedback) to [email protected] from his/her mobile.

i am using drupal6 for all my services so please tell me how to access drupal api to send mail using javascript

Thank you..!

Upvotes: 1

Views: 2833

Answers (1)

Jasper
Jasper

Reputation: 75993

You can submit your feedback form to a server-side script:

HTML --

<form data-ajax="false">
   ...
</form>

The data-ajax="false" is so jQuery Mobile does not handle the form submission on its own.

JS --

$('form').bind('submit', function () {
    $.ajax({
        url     : 'http://myserver.com/myscript.php',

        //add the forms input namv/value pairs to the AJAX request
        data    : $(this).serialize(),
        success : function (serverResponse) { /*Here you can confirm the message was sent to the user*/ },
        error   : function (jqXHR, textStatus, errorThrown) { /*Don't forget to handler errors*/ }
    });

    //stop the form from submitting normally
    return false;
});

PHP --

//create a message to send
$message = "Title: " . $_GET['title'] . "\n" .
           "Body: " . $_GET['body'];

//send the message
mail('[email protected]', 'App Feedback', $message);

Since you are using PhoneGap, you can get the device's unique ID or version information and append it to your form submission.

http://docs.phonegap.com/en/1.5.0/phonegap_device_device.md.html#Device

Upvotes: 1

Related Questions