1

I am developing a mobile application, one of it's features is to send an email from the users device. I want to be able to do this without prompting the user, so that it is sent in the background. (It is meant for an emergency use, so therefore the user shouldn't have to press send). I have tried the standard MAILTO:someone@example.com but this still prompts the user.

I am using a PhoneGap Service, so PhoneGap Plugins are an option, however the ones I've tried still prompt the user to send the email.

Any suggestions would be appreciated.

EDIT:

These are the two email plugins that I have tried.

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

https://github.com/jcjee/email-composer/tree/40e4b39dbd0d8605e4859b137d03f4a47262a35d

Thanks.

Jack
  • 21
  • 2
  • 8
  • 2
    Why don't you set up a mail server with a PHP script that will wait for your instructions and execute it when it receives a `mail.php?to=xx@yy.zz&subject=Emergency&body=testtesttesttest` – James Wong Nov 07 '14 at 01:46
  • That would be a possibility, and I have thought of setting up a server for it. Would there not be an easier way however? – Jack Nov 07 '14 at 08:43
  • In that case you may have to browse Java library that handles mail. See this: http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a – James Wong Nov 07 '14 at 11:05

1 Answers1

0

There is a way to send emails from javascript client, without prompting the user, i.e using Amazon SES service. You just need to register a valid email in the Amazon Console and all the emails will be sent with this id as the sender.

Include the aws .js, by creating your own minified version from AWS Builder. Refer here. Include this .js file in your www -> js folder & include the same in the .html section.

AWS.config.update({region: '<your_region>'});
AWS.config.update({apiVersion: '2010-12-01'});
var ses = new window.AWS.SES({"accessKeyId": "your_access_key", "secretAccessKey": "your_secret_key", "region": "<your_region>"});
  1. To send a simple email (without attachment) use the sendEmail function.

    sendEmail({
        subject: "Hello, World!",
        text: "This mail has been sent from the javascript client",
        to: "<receiver@email.com>"
      });
    
  2. To send an email with attachment use the sendRawEmail function. I have provided an detailed explanation here .

javatogo
  • 308
  • 1
  • 11