How to send email in PhoneGap (Android) using a gmail account

You may also like...

22 Responses

  1. How do you create a simple html form for the email to send with this tutorial? I am kinda a noob to javascript still lol.

  2. amit says:

    how to add “To field” dynamically in “window.EmailComposer.prototype.send(“My message body”);” like if i want “window.EmailComposer.prototype.send(“To”, “My message body”);”

  3. tomjm says:

    I could not find the Additional.jar file but i managed the rest of your instructions and tested it. I keep getting the alert: feedback was not sent. This means that startActivity() is failing. Does any1 know why this could be?

  4. Abdulqadir says:

    Can you please modify this plugin for Cordova-2.2.js latest phonegap version?

  5. razor8 says:

    How do you send the e-mail as html?

  6. seedorf says:

    I need someone to walk me through the process step by step because i am getting errors like “Create CommandMap’ in package ‘java.activation’

  7. jyothi says:

    Hi, I am using cordova2.1.0 and have done every thing you have told . I get “Result of expression’window.EmailComposer'[Undefined] is not an object” … not able to figure out

  8. This was very very helpful ! I liked the way you explain everything.
    For those who are using this, if you are using the latest version of phonegap – cordova 2.7.0 right now, please make sure you change the file to the latest execute method.
    Here is my java file (just in case you cannot figure out) –

    package com.example.phonegap;

    import org.apache.cordova.api.CallbackContext;
    import org.apache.cordova.api.CordovaPlugin;
    import org.json.JSONArray;
    import org.json.JSONException;

    import android.annotation.SuppressLint;

    public class EmailComposer extends CordovaPlugin {
    public final String ACTION_SEND_EMAIL = “sendEmail”;
    // CHECK THIS :
    public boolean execute(String action, JSONArray arg1, CallbackContext callbackContext) {
    //PluginResult result = new PluginResult(Status.INVALID_ACTION);
    if (action.equals(ACTION_SEND_EMAIL)) {
    try {
    String message = arg1.getString(0);
    return true;
    catch (JSONException ex) {
    return false;
    } catch (Exception e) {
    // TODO Auto-generated catch block
    return false;

    private void sendEmailViaGmail(String body) throws Exception{
    Mail m = new Mail(“”, “password”);
    String[] toArr = {“”};
    boolean sendFlag = m.send();



    • Karthikeyan Subramani says:

      Is this code working for you.. i am getting following error “The Jar of this class file belongs to container ‘android dependencies’ which does not allow modification to the source attachments in its entries”.

      • Yes it is working for me. Please update to latest cordova version. See Nikhil’s code in the comment which shows you how to make changes for latest cordova version.

    • Thank you for posting the updated the code. The version of cordova that I used is quite outdated now and your code should help others who are using the latest version.

  9. Sahil says:

    I found a way on how to make this send HTML emails. Anyone looking for a solution of the same problem please follow the guide below:

    You can make this send HTML content by replacing this bit of the ‘send()’ method in file:

    // setup message body
    BodyPart messageBodyPart = new MimeBodyPart();


    // setup message body
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setContent(_body, “text/html”);

  10. Animesh Pradhan says:

    How do i set TO , FROM , SUBJECT and BODY from User Input as because I have already set it in the .

  11. Alan Hoffmann-Hansen says:

    I keep getting error :Could not find class ‘’, referenced from method and Uncaught Error: Error calling method on NPObject. at file:///android_asset/www/cordova??

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>