How to send email through PhoneGap? html mailto is not working in device.
- 16 Posts
- 0 Reply Likes
Posted 4 years ago
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
html mailto: is 'working' properly in a device (although it's not the most eleant way to do this, just like using mailto: on a website).
Anyway, which devices are you talking about (what OS and version), how did you whitelist the mailto intent and how are you sure that there's a mail client installed?
Anyway, which devices are you talking about (what OS and version), how did you whitelist the mailto intent and how are you sure that there's a mail client installed?
- 3 Posts
- 0 Reply Likes
- 16 Posts
- 0 Reply Likes
Hi Sushant,
My requirement is send html form details entered to send email from the app. Is it neccessary to use emailcomposer plugin? Cant i send email using html mailto? Can you please share sample code to send email with phonegap using emailcomposer including config.xml code. Also how to use emailcomposer plugin and how to call emailcomposer.js from html as i am very new to phonegap.
My requirement is send html form details entered to send email from the app. Is it neccessary to use emailcomposer plugin? Cant i send email using html mailto? Can you please share sample code to send email with phonegap using emailcomposer including config.xml code. Also how to use emailcomposer plugin and how to call emailcomposer.js from html as i am very new to phonegap.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
It's written out in the plugin's docs. Is there anything specifically which you don't understand?
https://github.com/katzer/cordova-plu...
cordova.plugins.email.open({
app: 'mailto',
subject: 'Sent with mailto'
})
https://github.com/katzer/cordova-plu...
- 16 Posts
- 0 Reply Likes
Hi Petra,
Code mentioned in docs is js function. How to invoke open function by just calling open() from html or js , or by calling cordova.plugins.email.open() as mentioned in docs. In some sites code is window.plugin.email.open(). So i am confused. Please help how to invoke open() function.
Code mentioned in docs is js function. How to invoke open function by just calling open() from html or js , or by calling cordova.plugins.email.open() as mentioned in docs. In some sites code is window.plugin.email.open(). So i am confused. Please help how to invoke open() function.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
I am not quite sure what it is you are asking.
You confirm that this is a javascript function (which it is). The funcion itself is defined in the plugin, so you don't need to worry about that.
If you have a html form with input fields for subject, message, recipient, you simply catch the 'submit' event and in the eventListeners's callback function you:
- set the values for the appropriate object attributes in
- call that function
- check for the result in the callback function.
Make sure you first use the isAvailable() function to check for an installed mail client. Otherwise, you shouldn't even display the form.
You confirm that this is a javascript function (which it is). The funcion itself is defined in the plugin, so you don't need to worry about that.
If you have a html form with input fields for subject, message, recipient, you simply catch the 'submit' event and in the eventListeners's callback function you:
- set the values for the appropriate object attributes in
cordova.plugins.email.open({
to: Array, // email addresses for TO field
cc: Array, // email addresses for CC field
bcc: Array, // email addresses for BCC field
attachments: Array, // file paths or base64 data streams
subject: String, // subject of the email
body: String, // email body (for HTML, set isHtml to true)
isHtml: Boolean, // indicats if the body is HTML or plain text
}, callback, scope);
- call that function
- check for the result in the callback function.
Make sure you first use the isAvailable() function to check for an installed mail client. Otherwise, you shouldn't even display the form.
- 16 Posts
- 0 Reply Likes
Hi Petra,
I am doing following
1. Downloaded phonegap emailcomposer plugin (zip) from https://github.com/katzer/cordova-plu...
2. I have placed cordova-plugin-email-composer folder into the plugin folder of phonegap project created by phonegap desktop app
3. Added to the config.xml
4. In my html code is
5. In my js code is (just for testing purpose)
function sendEmail(){
cordova.plugins.email.open({
to: 'max@mustermann.de',
cc: 'erika@mustermann.de',
bcc: ['john@doe.com', 'jane@doe.com'],
subject: 'Greetings',
body: 'How are you? Nice greetings from Leipzig'
});
}
6. Building in phonegap desktop app
7. Running in phonegap mobile app
When i test this mail client is not opening.
Please let me know whether i am doing correctly ? or i have to build my phonegap locally using phonegap CLI?
I am doing following
1. Downloaded phonegap emailcomposer plugin (zip) from https://github.com/katzer/cordova-plu...
2. I have placed cordova-plugin-email-composer folder into the plugin folder of phonegap project created by phonegap desktop app
3. Added to the config.xml
4. In my html code is
5. In my js code is (just for testing purpose)
function sendEmail(){
cordova.plugins.email.open({
to: 'max@mustermann.de',
cc: 'erika@mustermann.de',
bcc: ['john@doe.com', 'jane@doe.com'],
subject: 'Greetings',
body: 'How are you? Nice greetings from Leipzig'
});
}
6. Building in phonegap desktop app
7. Running in phonegap mobile app
When i test this mail client is not opening.
Please let me know whether i am doing correctly ? or i have to build my phonegap locally using phonegap CLI?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
I will try to use CLI for local and PGB for cloud build.Which one are you using now? If the latter, then don't download the plugin, don't use the developer app.
(4): When posting code at this forum, wrap it in a CODE element as described under "some HTML allowed"
(5) After which event, action or condition do you call your function sendEmail(), then?
Now, I am not sure whether or not this is the proper procedure. This is the Phonegap Build community. If you insist on using the CLI and/or developer app, you'd better ask your question in the Phonegap Google Group.
JesseMonroy650 (Volunteer), Champion
- 3325 Posts
- 122 Reply Likes
@Sushant,
You cannot use Phonegap Desktop App with Phonegap Build.
Phonegap Build is a cloud-based build system you upload your files to.
Are you using Phonegap Build? This forum is for supporting Phonegap Build. If you are using the CLI (Command Line Interface), you should be on Google Groups for Phonegap _or_ Adobe forums for Phonegap CLI
Jesse
You cannot use Phonegap Desktop App with Phonegap Build.
Phonegap Build is a cloud-based build system you upload your files to.
Are you using Phonegap Build? This forum is for supporting Phonegap Build. If you are using the CLI (Command Line Interface), you should be on Google Groups for Phonegap _or_ Adobe forums for Phonegap CLI
Jesse
Related Categories
-
PhoneGap Framework
- 2926 Conversations
- 61 Followers
-
PhoneGap Build
- 15111 Conversations
- 275 Followers




Petra V., Champion
- Are you building with Phonegap Build, or do you build locally?
- If PGB, then you need to change the config and the directory structure as generated by the desktop client. PGB wants both config and index.html in the root of your zip file. And only upload your assets, not a full Cordova project.
- You don't "install" plugins when using PGB. Just reference the plugin as described in the plugin's docs and as described in the Plugins section of the Phonegap Build documentation (link in menu bar of this forum)
Sandeep Karnam
1. Installed PhoneGap Desktop app in windows machine and PhoneGap Developer app (mobile app) in my android phone from play store as mentioned in the phonegap website. http://phonegap.com/
2. Created a new phonegap app PhoneGap Desktop app, which generated phonegap project structure (www folder, config.xml,...) in my windows local drive.
3. I am modifying www folder as per my app requirement.
4. I am pushing the code to server from PhoneGap Desktop app. It displays server url
5. I am testing in my phone through phonegap mobile app by entering server url diplayed in PhoneGap Desktop app and submit.
Please let me know whether i am following the right procedure if not suggest me with the right procedure.
Petra V., Champion
You could instead stop using the Phonegap desktop app now, add the plugin through the CLI, then build your app locally with CLI as described in the Phonegap documentation. The plugin will then be included and you can follow the docs from there.
This here is the Phonegap Build forum, the place for developers who don't go through the hassle of installing and maintaining Phonegap, SDK's, Java, plugins, Node and whatnot. PGB is a service that allows developers to build in the cloud, not locally.
So, you may be a bit lost here. You would more likely get better help at the Phonegap Google Group or at Stackoverflow.
Sandeep Karnam
Sandeep Karnam
How to call cordova.plugins.email.open() function.