Ionic/Cordova Plugin Development - A beginner question


I’m starting with Ionic and I’m just amazed on how awesome this framework is! So first, good job and thanks!

What I want: I’m developing an ionic android (plan to move to others platforms later) app which will simple take or select a picture and send it to an e-mail address along with some fields. As far as my research went, I couldn’t find a cordova plugin to send e-mails without the user having to interact with it. There’s plugins for this but all of them open the “native” e-mail client which is not what I want.

My Plan: So my idea was to build a Java class to send the e-mail in a “silent” and transparent way for the user. (I’m aware that I will need to use a fixed e-mail address, that’s Ok for now). I worked with Phonegap once and I’m kind of familiar on how to create a plugin, but how about Ionic? It seems to me that theres not much information around this subject.

My question: I already created the UI and everything works great. I’m using the command-line for everything (build, emulate, run) and I pretend to continue doing because it is just so easy. So now I want to start building the plugin, and I’m wondering, how do I do it?

  • Do I have to do it in a separeted android project, then “install it” like a normal plugin?
  • Do I have to import my Ionic Android project to Eclipse and start working there?
  • If I do the above, when I execute : Ionic build android, wouldn’t I lose everything I did in the Android platform folder?

Sorry for the long post, but if anyone can clear things up and provide some guidance, man, that would be great!

Big Thanks!

Edit: I know that having a back-end infrastructure to send the e-mails would be better, but this is not the point of my question as the client doesn’t want to pay for a host/storage/domain and etc.


I don’t think there’s anything Ionic-specific about plugins, so I would look at the Cordova documentation.


Why not just send it to a php server which would forward it?


Yes, ysrael, that was my first “approach” to solve this and of course way better than send via email. But the client who asked for the app doesn’t want to spend money on a host server. Yeah… I know, so that’s that.


Like ysrael said, you can use a backend server. Yes, is the best solution… I think!
For example, you can make an API endpoint and send email internaly (with sendmail, mailgun, … and others).


Sure, an API would be the perfect world, I know that. But, as I mentioned before, a back=end infrastructure is not available for now (bottom line, the client doesn’t want to pay for it).

I think my question wasn’t clear enough. I’m aware of the scenario here. A back-end solution is the right way to go. My point with this question was more about a “flow” to create a plugin. The Cordova documentation helped me get started but still there’s a lot of missing points which I listed in my question.

Also, I think a plugin to send e-mails “silently” does not quiet exist (at least I couldn’t find it) and would be interesting to build it even though was only for self study.


I just wrote a plugin for connecting to Twitter so I have some experience.

What you’ll want to do is write the plugin just like the Cordova docs say and then write an angular wrapper around the JavaScript (although you could write the plugin’s JavaScript in angular if you wanted to).

I found the most help in looking at other plugins and how they were written.

Edit: I can’t figure out how to add a link on mobile.


Android (and maybe iOS) won’t let you send background emails. It is deemed a security concern by the device operating system.


Is this really true? I ask because in the emulator it works, but on my phone it doesn’t.


There’s no security problem with the emulator, that’s probably why it works.


Both Android and IOS systems do not allow email without user input first. Think about it, this would be easily exploited by spammers.

Tell your client that an API with a server is the only way (because it is). Cloud services/ storage is so cheap now, I doubt the cost of maintaining the server would even be significant.


this is A plugs develeper dome


but it is.develeped by Chinese

good luck!