user1543269
user1543269

Reputation: 57

Sending Email on PhoneGap

I am trying to send an email on PhoneGap. I've seen a few different EmailComposer plugins, but I wanted to see if there was a simpler way to send an email without a plugin. I've tried using the mailto command like this:

<a href="mailto:[email protected]?Subject=Hello">Send Mail</a>

When I run this on the iPhone simulator and click on the link I get this message in the console log:

AppDelegate::shouldStartLoadWithRequest: Received Unhandled URL mailto:[email protected]?Subject=Hello%20again

Is it possible to use the mailto command to send an email or do I need to use a plugin? If I can use the mailto command what can I change to make it work? Also, what would be the advantage to using a plugin versus the mailto command?

Thank you in advance!

Upvotes: 1

Views: 2364

Answers (2)

Rahul Nanwani
Rahul Nanwani

Reputation: 1277

I myself wanted to send a mail from a phonegap app and didnt want to go for a plugin. So I have thought of this solution to send a mail.

  • Send an ajax request to a server side script that can send mails (like PHP - that is what my server side scripts are written in).
  • In the data for the ajax request, send all the data you want in the mail, body, attachments etc.
  • Construct the mail in PHP and send the mail.
  • On successful send, respond back with a JSON object indicating the status.
  • Use the callback function of the ajax script to provide the user a notification about the same (success or failure).

I will share the code, if this works, as soon as I am done with it.

Upvotes: 0

Anil
Anil

Reputation: 1028

You need to use the phonegap plugin EmailComposer .

Mailto command won't work on all platforms. That's the reason why this plugin is mostly used.

Github link

All the guidelines to use it can be found at it's readme.txt

Upvotes: 1

Related Questions