@capawesome/capacitor-mail-composer 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +62 -3
  2. package/package.json +11 -4
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @capawesome/capacitor-mail-composer
1
+ # Capacitor Mail Composer Plugin
2
2
 
3
3
  Capacitor plugin to open the native email composer.
4
4
 
@@ -19,9 +19,14 @@ Capacitor plugin to open the native email composer.
19
19
 
20
20
  Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
21
21
 
22
- ## Newsletter
22
+ ## Use Cases
23
23
 
24
- Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
24
+ The Mail Composer plugin is typically used whenever an app wants the user to send an email, for example:
25
+
26
+ - **Support and feedback**: Open a prefilled email to your support address with a subject and body so users can reach out with one tap.
27
+ - **Bug reports**: Attach log files or screenshots to a bug report email using the `attachments` option.
28
+ - **Sharing content**: Let users share content from your app via email with prefilled recipients, subject, and body.
29
+ - **Invitations**: Prefill invitation emails with CC and BCC recipients that the user only needs to review and send.
25
30
 
26
31
  ## Compatibility
27
32
 
@@ -71,6 +76,12 @@ No configuration required for this plugin.
71
76
 
72
77
  ## Usage
73
78
 
79
+ The following examples show how to check whether the device can send emails and how to open the native email composer.
80
+
81
+ ### Check whether the device can send emails
82
+
83
+ Before opening the composer, check whether the device is able to compose and send emails. On iOS, this returns `true` only if a mail account is configured. On Android, it returns `true` if a mail app is installed. On the web, it always returns `true`:
84
+
74
85
  ```typescript
75
86
  import { MailComposer } from '@capawesome/capacitor-mail-composer';
76
87
 
@@ -78,6 +89,14 @@ const canComposeMail = async () => {
78
89
  const { canCompose } = await MailComposer.canComposeMail();
79
90
  return canCompose;
80
91
  };
92
+ ```
93
+
94
+ ### Compose an email
95
+
96
+ Open the native email composer prefilled with recipients, subject, and body. The user reviews the email and decides whether to send it. Note that on Android, the returned `status` is always `unknown`:
97
+
98
+ ```typescript
99
+ import { MailComposer } from '@capawesome/capacitor-mail-composer';
81
100
 
82
101
  const composeMail = async () => {
83
102
  const { status } = await MailComposer.composeMail({
@@ -199,6 +218,46 @@ Keep the following platform-specific behavior in mind:
199
218
  - **HTML body**: On Android, the `isHtml` option is best-effort because many mail apps ignore HTML content. On the web, HTML is not supported at all.
200
219
  - **No mail account**: On iOS, `composeMail(...)` rejects as unavailable if no mail account is configured. Use `canComposeMail(...)` to check upfront.
201
220
 
221
+ ## FAQ
222
+
223
+ ### How is this plugin different from other similar plugins?
224
+
225
+ It opens the native email composer prefilled with recipients, subject, body, and CC and BCC, and supports file attachments and HTML bodies through a fully typed API on Android, iOS, and the Web. A `canComposeMail()` check lets you confirm the device can actually send mail before you show the feature, and the user always stays in control of sending. If you only need a plain `mailto:` link, a simpler approach is fine; if you need attachments, rich bodies, and reliable capability detection, this plugin is built for exactly that.
226
+
227
+ ### Does the plugin send the email itself?
228
+
229
+ No, the plugin only opens the native email composer prefilled with the provided data. The user reviews the email and decides whether to send it. The email is always sent through the user's own mail app and account.
230
+
231
+ ### Why is the status always `unknown` on Android?
232
+
233
+ On Android, the mail intent does not return a reliable result, so the `status` returned by `composeMail` is always `unknown`. On iOS, the real status (`sent`, `saved`, or `canceled`) is returned. On the web, the status is always `unknown` as well.
234
+
235
+ ### Why does `composeMail` reject on iOS?
236
+
237
+ On iOS, `composeMail` rejects as unavailable if no mail account is configured on the device. Use `canComposeMail` upfront to check whether the device is able to compose and send emails, and only show your email feature if it returns `true`.
238
+
239
+ ### Why does attaching a file fail on Android?
240
+
241
+ On Android, the plugin shares attachments through the [`FileProvider`](https://developer.android.com/reference/androidx/core/content/FileProvider) that Capacitor already registers for your app. If the directory a file is stored in is not covered by the `res/xml/file_paths.xml` resource of your app, `composeMail` rejects with an error. See the [Installation](#installation) section for details.
242
+
243
+ ### Are attachments supported on the web?
244
+
245
+ No, on the web the plugin builds a `mailto:` URL, which cannot carry attachments, so `composeMail` rejects if attachments are provided. Also keep in mind that HTML bodies are not supported on the web and long bodies may be truncated due to the URL length limit.
246
+
247
+ ### Can I send HTML emails?
248
+
249
+ Yes, set the `isHtml` option to `true` to have the body interpreted as HTML. On iOS, this is fully supported. On Android, it is best-effort because many mail apps ignore HTML content. On the web, HTML is not supported and the body is always sent as plain text.
250
+
251
+ ## Related Plugins
252
+
253
+ - [SMS Composer](https://capawesome.io/docs/sdks/capacitor/sms-composer/): Open the native SMS composer prefilled with recipients and a message body.
254
+ - [Phone Dialer](https://capawesome.io/docs/sdks/capacitor/phone-dialer/): Open the native phone dialer prefilled with a phone number.
255
+ - [File Picker](https://capawesome.io/docs/sdks/capacitor/file-picker/): Let the user select files to attach to an email.
256
+
257
+ ## Newsletter
258
+
259
+ Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
260
+
202
261
  ## Changelog
203
262
 
204
263
  See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/mail-composer/CHANGELOG.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-mail-composer",
3
- "version": "0.0.1",
4
- "description": "Capacitor plugin to open the native email composer.",
3
+ "version": "0.1.0",
4
+ "description": "Capacitor plugin to open the native email composer on Android, iOS, and Web.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/esm/index.d.ts",
@@ -33,11 +33,18 @@
33
33
  "url": "https://opencollective.com/capawesome"
34
34
  }
35
35
  ],
36
- "homepage": "https://capawesome.io/docs/plugins/mail-composer/",
36
+ "homepage": "https://capawesome.io/docs/sdks/capacitor/mail-composer/",
37
37
  "keywords": [
38
38
  "capacitor",
39
+ "capacitor-plugin",
39
40
  "plugin",
40
- "native"
41
+ "native",
42
+ "mail composer",
43
+ "email composer",
44
+ "email",
45
+ "send email",
46
+ "mailto",
47
+ "email attachments"
41
48
  ],
42
49
  "scripts": {
43
50
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",